Skip to content

Commit da13a29

Browse files
committed
Add option log
1 parent 45d925a commit da13a29

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 5.2.0
2+
3+
## Features
4+
5+
- Add option [`log`](README.md#-log) to customize printing the error message.
6+
17
# 5.1.0
28

39
## Features

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exits the process.
2222
- 🚒 [Graceful exit](#-timeout)
2323
- ⛑️ [Normalize](https://github.com/ehmicky/normalize-exception) invalid errors
2424
- 🔕 Log verbosity: [message](#-silent), [stack](#-stack), [properties](#-props)
25-
- 🚨 Custom [exit code](#-exitcode)
25+
- 🚨 Custom [exit code](#-exitcode) and [log function](#-log)
2626
- 💥 Exception-safe
2727

2828
# Screenshot
@@ -176,6 +176,13 @@ Special values:
176176
- `Number.POSITIVE_INFINITY`: Waits for ongoing tasks forever, without timing
177177
out
178178

179+
#### 📜 log
180+
181+
_Type_: `(string) => void`\
182+
_Default_: `console.error`
183+
184+
Function used to print the error message.
185+
179186
## Configuration
180187

181188
[Options](#options) can apply to (in priority order):

src/main.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ const BaseError = ModernError.subclass('BaseError', {
4343
const error = new BaseError(message)
4444

4545
each(
46-
[true, { timeout: 'true' }, { unknown: true }, { classes: {} }],
46+
[
47+
true,
48+
{ timeout: 'true' },
49+
{ log: true },
50+
{ unknown: true },
51+
{ classes: {} },
52+
],
4753
({ title }, options) => {
4854
test(`Options are validated | ${title}`, (t) => {
4955
// @ts-expect-error Type checking should fail due to invalid options

0 commit comments

Comments
 (0)