handle-cli-error
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -60,3 +60,3 @@ /** | ||
* DatabaseError: { exitCode: 2, short: true }, | ||
* InternalError: { exitCode: 3 }, | ||
* default: { exitCode: 3 }, | ||
* }) | ||
@@ -63,0 +63,0 @@ * ``` |
export const printError=function(error,silent,short){ | ||
if(silent){ | ||
return; | ||
if(!silent){ | ||
console.error(getErrorMessage(error,short)); | ||
} | ||
}; | ||
const errorMessage=short?error.message:error.stack; | ||
console.error(errorMessage); | ||
const getErrorMessage=function({name,message,stack},short){ | ||
if(short){ | ||
return message; | ||
} | ||
return stack.includes(name)&&stack.includes(message)? | ||
stack: | ||
`${name}: ${message}\n${stack}`; | ||
}; | ||
//# sourceMappingURL=print.js.map |
{ | ||
"name": "handle-cli-error", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"type": "module", | ||
@@ -52,3 +52,3 @@ "exports": "./build/src/main.js", | ||
"execa": "^6.1.0", | ||
"test-each": "^5.2.0" | ||
"test-each": "^5.2.1" | ||
}, | ||
@@ -61,4 +61,4 @@ "engines": { | ||
"is-plain-obj": "^4.1.0", | ||
"normalize-exception": "^1.5.0" | ||
"normalize-exception": "^2.1.0" | ||
} | ||
} |
@@ -7,4 +7,4 @@ <picture> | ||
[![Codecov](https://img.shields.io/codecov/c/github/ehmicky/handle-cli-error.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/handle-cli-error) | ||
[![Node](https://img.shields.io/node/v/handle-cli-error.svg?logo=node.js)](https://www.npmjs.com/package/handle-cli-error) | ||
[![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/handle-cli-error.svg?logo=node.js&logoColor=66cc33)](https://www.npmjs.com/package/handle-cli-error) | ||
[![Twitter](https://img.shields.io/badge/%E2%80%8B-twitter-brightgreen.svg?logo=twitter)](https://twitter.com/intent/follow?screen_name=ehmicky) | ||
@@ -50,3 +50,3 @@ [![Medium](https://img.shields.io/badge/%E2%80%8B-medium-brightgreen.svg?logo=medium)](https://medium.com/@ehmicky) | ||
DatabaseError: { exitCode: 2, short: true }, | ||
InternalError: { exitCode: 3 }, | ||
default: { exitCode: 3 }, | ||
}, | ||
@@ -138,4 +138,5 @@ }) | ||
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 | ||
@@ -149,2 +150,4 @@ errors to/from plain objects | ||
Polyfill `error.cause` | ||
- [`log-process-errors`](https://github.com/ehmicky/log-process-errors): Show | ||
some ❤ to Node.js process errors | ||
@@ -151,0 +154,0 @@ # Credits |
25925
241
182
+ Addedis-error-instance@1.6.0(transitive)
+ Addednormalize-exception@2.11.0(transitive)
- Removednormalize-exception@1.9.0(transitive)
Updatednormalize-exception@^2.1.0