normalize-exception
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -0,1 +1,7 @@ | ||
type DefinedString<Value, DefaultValue> = Value extends string | ||
? Value extends '' | ||
? DefaultValue | ||
: Value | ||
: DefaultValue | ||
/** | ||
@@ -46,2 +52,9 @@ * Normalize exception/error. | ||
*/ | ||
export default function normalizeException(error: unknown): Error | ||
export default function normalizeException<ErrorArg>( | ||
error: ErrorArg, | ||
): ErrorArg extends Error | ||
? Error & { | ||
name: DefinedString<ErrorArg['name'], Error['constructor']['name']> | ||
message: DefinedString<ErrorArg['message'], ''> | ||
} | ||
: Error |
@@ -52,3 +52,2 @@ import{setErrorProperty}from"./descriptors.js"; | ||
const findInternalIndex=function(lines){ | ||
@@ -55,0 +54,0 @@ const index=findLastIndex(lines,isInternalStackLine); |
{ | ||
"name": "normalize-exception", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"type": "module", | ||
@@ -50,3 +50,3 @@ "exports": "./build/src/main.js", | ||
"@ehmicky/dev-tasks": "^1.0.84", | ||
"test-each": "^5.2.0" | ||
"test-each": "^5.2.1" | ||
}, | ||
@@ -53,0 +53,0 @@ "engines": { |
[![Codecov](https://img.shields.io/codecov/c/github/ehmicky/normalize-exception.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/normalize-exception) | ||
[![Node](https://img.shields.io/node/v/normalize-exception.svg?logo=node.js)](https://www.npmjs.com/package/normalize-exception) | ||
[![TypeScript](https://img.shields.io/badge/-typed-brightgreen?logo=typescript&colorA=gray)](/src/main.d.ts) | ||
[![TypeScript](https://img.shields.io/badge/-typed-brightgreen?logo=typescript&colorA=gray&logoColor=0096ff)](/src/main.d.ts) | ||
[![Node](https://img.shields.io/node/v/normalize-exception.svg?logo=node.js&logoColor=66cc33)](https://www.npmjs.com/package/normalize-exception) | ||
[![Twitter](https://img.shields.io/badge/%E2%80%8B-twitter-brightgreen.svg?logo=twitter)](https://twitter.com/intent/follow?screen_name=ehmicky) | ||
@@ -322,4 +322,5 @@ [![Medium](https://img.shields.io/badge/%E2%80%8B-medium-brightgreen.svg?logo=medium)](https://medium.com/@ehmicky) | ||
like it's 2022 🔮 | ||
- [`error-type`](https://github.com/ehmicky/error-type): Create custom error | ||
types | ||
- [`create-error-types`](https://github.com/ehmicky/create-error-types): Create | ||
multiple error types | ||
- [`error-type`](https://github.com/ehmicky/error-type): Create one error type | ||
- [`error-serializer`](https://github.com/ehmicky/error-serializer): Convert | ||
@@ -333,2 +334,4 @@ errors to/from plain objects | ||
handler for CLI applications 💥 | ||
- [`log-process-errors`](https://github.com/ehmicky/log-process-errors): Show | ||
some ❤ to Node.js process errors | ||
@@ -335,0 +338,0 @@ # Support |
34111
429
363