Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Oct 30, 2022
1 parent 89ad16d commit 24333c2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
[plugin](https://github.com/ehmicky/modern-errors#plugins-1) to handle errors in
CLI modules.

This adds `error.exit()` which logs `error` then exits the process.
This adds [`error.exit()`](#errorexit) which logs `error` then exits the
process.

# Features

Expand Down Expand Up @@ -42,8 +43,7 @@ export const AnyError = modernErrors([modernErrorsCli])
// ...
```

Calling [`error.exit()`](#errorexitoptions) in the CLI's top-level error
handler.
Calling [`error.exit()`](#errorexit) in the CLI's top-level error handler.

```js
#!/usr/bin/env node
Expand All @@ -53,8 +53,10 @@ const cliMain = function () {
try {
// ...
} catch (error) {
// Ensure `error` is an `Error` instance
const normalizedError = AnyError.normalize(error)
normalizedError.exit() // Logs `error` then exit the process
// Logs `error` then exits the process
normalizedError.exit()
}
}

Expand Down

0 comments on commit 24333c2

Please sign in to comment.