Skip to content

Commit b928865

Browse files
committed
Fix types documentation
1 parent b5d4078 commit b928865

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

types/main.d.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
type NormalizeError<ErrorArg> = ErrorArg extends Error ? ErrorArg : Error
22

33
/**
4-
* Sets `error.message = newMessage`.
4+
* Sets `error.stack = stack`.
5+
* If needed, also modifies `error.message` accordingly.
56
*
6-
* Returns `error`. If `error` is not an `Error` in
7-
* stance, it is converted to one.
8-
*
9-
* If `error.stack` contains `currentMessage`, it is replaced by `newMessage`.
10-
* `currentMessage` is the error message currently included in `error.stack`. It
11-
* defaults to `error.message`, which is usually best.
7+
* Returns `error`. If `error` is not an `Error` instance, it is converted to
8+
* one.
129
*
1310
* @example
1411
* ```js
1512
* const error = new Error('one')
16-
* console.log(error.message) // 'one'
1713
* console.log(error.stack) // 'Error: one ...'
14+
* console.log(error.message) // 'one'
1815
*
19-
* setErrorStack(error, 'two')
20-
* console.log(error.message) // 'two'
16+
* setErrorStack(error, error.stack.replace('one', 'two'))
2117
* console.log(error.stack) // 'Error: two ...'
18+
* console.log(error.message) // 'two'
2219
* ```
2320
*/
2421
export default function setErrorStack<ErrorArg>(

0 commit comments

Comments
 (0)