modern-errors
Advanced tools
Comparing version 4.0.0-beta.4 to 4.0.0
{ | ||
"name": "modern-errors", | ||
"version": "4.0.0-beta.4", | ||
"version": "4.0.0", | ||
"type": "module", | ||
@@ -49,2 +49,3 @@ "exports": { | ||
"directories": { | ||
"example": "examples", | ||
"lib": "src", | ||
@@ -66,9 +67,9 @@ "test": "test" | ||
"is-error-instance": "^1.1.0", | ||
"modern-errors-bugs": "^1.0.0", | ||
"modern-errors-cli": "^1.1.0", | ||
"modern-errors-http": "^1.0.0", | ||
"modern-errors-process": "^1.0.0", | ||
"modern-errors-serialize": "^1.0.0", | ||
"modern-errors-stack": "^1.0.0", | ||
"modern-errors-winston": "^1.0.0", | ||
"modern-errors-bugs": "^1.1.0", | ||
"modern-errors-cli": "^1.2.0", | ||
"modern-errors-http": "^1.1.0", | ||
"modern-errors-process": "^1.1.0", | ||
"modern-errors-serialize": "^1.1.0", | ||
"modern-errors-stack": "^1.1.0", | ||
"modern-errors-winston": "^1.1.0", | ||
"test-each": "^5.4.0" | ||
@@ -75,0 +76,0 @@ }, |
@@ -18,16 +18,16 @@ <picture> | ||
- Create [error classes](#create-error-classes) (including with | ||
[custom logic](#custom-logic)) | ||
- Set properties on [individual errors](#error-instance-properties) or on | ||
- ⛑️ Create [error classes](#create-error-classes) (including with | ||
[custom logic](#-custom-logic)) | ||
- 🏷️ Set properties on [individual errors](#error-instance-properties) or on | ||
[all errors of the same class](#error-class-properties) | ||
- Wrap errors' [message](#wrap-error-message), [class](#wrap-error-class) and | ||
- 🎀 Wrap errors' [message](#wrap-error-message), [class](#wrap-error-class) and | ||
[properties](#wrap-error-options) | ||
- Separate known and [unknown errors](#unknown-errors) | ||
- Normalize [invalid errors](#invalid-errors) (not an `Error` instance, missing | ||
`stack`, etc.) | ||
- Strict [TypeScript types](docs/typescript.md) | ||
- Based on standard JavaScript: [`throw`](#throw-errors), | ||
[`try/catch`](#wrap-errors), [`new Error()`](#throw-errors), | ||
[`error.cause`](#wrap-errors), [`instanceof`](#check-error-classes), | ||
[`class`](#custom-logic), | ||
- 🚨 Normalize [invalid errors](#invalid-errors) (not an `Error` instance, | ||
missing `stack`, etc.) | ||
- 🐞 Separate known and [unknown errors](#-unknown-errors) | ||
- 🤓 Strict [TypeScript types](docs/typescript.md) | ||
- 📖 Based on standard JavaScript: [`throw`](#%EF%B8%8F-throw-errors), | ||
[`try/catch`](#-wrap-errors), [`new Error()`](#%EF%B8%8F-throw-errors), | ||
[`error.cause`](#-wrap-errors), [`instanceof`](#check-error-classes), | ||
[`class`](#-custom-logic), | ||
[`toJSON()`](https://github.com/ehmicky/modern-errors-serialize#errortojson) | ||
@@ -51,7 +51,7 @@ | ||
Log errors with Winston | ||
- Create your [own plugin](#custom-plugins) | ||
- 🔌 Create your [own plugin](docs/plugins.md) | ||
# Example | ||
Create [error classes](#error-classes). | ||
Create [error classes](#%EF%B8%8F-error-classes). | ||
@@ -70,3 +70,3 @@ ```js | ||
[Throw](#throw-errors) errors. | ||
[Throw](#%EF%B8%8F-throw-errors) errors. | ||
@@ -77,3 +77,3 @@ ```js | ||
[Wrap](#wrap-errors) errors. | ||
[Wrap](#-wrap-errors) errors. | ||
@@ -88,3 +88,3 @@ ```js | ||
[Normalize](#normalize-errors) errors. | ||
[Normalize](#-normalize-errors) errors. | ||
@@ -102,3 +102,3 @@ <!-- eslint-disable no-throw-literal --> | ||
Use [plugins](#plugins-1). | ||
Use [plugins](#-plugins). | ||
@@ -126,3 +126,3 @@ ```js | ||
If any [plugin](#plugins-1) is used, it must also be installed. | ||
If any [plugin](#-plugins) is used, it must also be installed. | ||
@@ -141,3 +141,3 @@ ```bash | ||
`plugins`: [`Plugin[]?`](#plugins-1)\ | ||
`plugins`: [`Plugin[]?`](#-plugins)\ | ||
`options`: `object?` | ||
@@ -163,3 +163,3 @@ | ||
Creates and returns an error subclass. The first one must be named | ||
[`UnknownError`](#unknown-errors). | ||
[`UnknownError`](#-unknown-errors). | ||
@@ -173,3 +173,3 @@ Subclasses can [also call](#shared-custom-logic) `ErrorClass.subclass()` | ||
- `props`: [error properties](#error-instance-properties) | ||
- `custom`: [custom class](#custom-logic) to add any methods, `constructor` or | ||
- `custom`: [custom class](#-custom-logic) to add any methods, `constructor` or | ||
properties | ||
@@ -183,3 +183,3 @@ | ||
Normalizes [invalid errors](#invalid-errors) and assigns the `UnknownError` | ||
class to [_unknown_ errors](#unknown-errors). | ||
class to [_unknown_ errors](#-unknown-errors). | ||
@@ -196,3 +196,3 @@ ### new AnyError(message, options?) | ||
- `props`: [error properties](#error-instance-properties) | ||
- `cause`: inner error being [wrapped](#wrap-errors). Required with | ||
- `cause`: inner error being [wrapped](#-wrap-errors). Required with | ||
[`AnyError`](#anyerror), optional with its | ||
@@ -204,3 +204,3 @@ [subclasses](#anyerrorsubclassname-options). | ||
## Error classes | ||
## ⛑️ Error classes | ||
@@ -223,3 +223,3 @@ ### Create error classes | ||
Exporting and documenting error classes (including [`AnyError`](#anyerror) and | ||
[`UnknownError`](#unknown-errors)) allows consumers to check them. This also | ||
[`UnknownError`](#-unknown-errors)) allows consumers to check them. This also | ||
enables sharing error classes between modules. | ||
@@ -246,3 +246,3 @@ | ||
## Throw errors | ||
## 🏷️ Throw errors | ||
@@ -290,3 +290,3 @@ ### Simple errors | ||
## Wrap errors | ||
## 🎀 Wrap errors | ||
@@ -391,3 +391,3 @@ ### Wrap inner error | ||
## Normalize errors | ||
## 🚨 Normalize errors | ||
@@ -397,3 +397,3 @@ ### Wrapped errors | ||
Any error can be directly passed to the [`cause` option](#wrap-inner-error), | ||
even if it is [invalid](#invalid-errors), [unknown](#unknown-errors) or not | ||
even if it is [invalid](#invalid-errors), [unknown](#-unknown-errors) or not | ||
[normalized](#anyerrornormalizeanyexception). | ||
@@ -448,3 +448,3 @@ | ||
[plugins](#using-plugins-with-unknown-errors), and has a class that is either | ||
[_known_](#create-error-classes) or [`UnknownError`](#unknown-errors). | ||
[_known_](#create-error-classes) or [`UnknownError`](#-unknown-errors). | ||
@@ -461,5 +461,5 @@ ```js | ||
### Unknown errors | ||
## 🐞 Unknown errors | ||
#### Normalizing unknown errors | ||
### Normalizing unknown errors | ||
@@ -483,3 +483,3 @@ An error is _unknown_ if its class was not created by | ||
#### Handling unknown errors | ||
### Handling unknown errors | ||
@@ -502,6 +502,6 @@ _Unknown_ errors should be handled in a `try {} catch {}` block and | ||
#### Using plugins with unknown errors | ||
### Using plugins with unknown errors | ||
[`AnyError.normalize()`](#anyerrornormalizeanyexception) is required for | ||
[_unknown_ errors](#unknown-errors) to use [plugins](#plugins-1). | ||
[_unknown_ errors](#-unknown-errors) to use [plugins](#-plugins). | ||
@@ -521,3 +521,3 @@ <!-- eslint-skip --> | ||
## Custom logic | ||
## 🔧 Custom logic | ||
@@ -579,3 +579,3 @@ ### Class custom logic | ||
## Plugins | ||
## 🔌 Plugins | ||
@@ -615,3 +615,3 @@ ### List of plugins | ||
const options = { | ||
// `modern-error-bugs` options | ||
// `modern-errors-bugs` options | ||
bugs: 'https://github.com/my-name/my-project/issues', | ||
@@ -669,3 +669,3 @@ // `props` can be configured and modified like plugin options | ||
## TypeScript | ||
## 🤓 TypeScript | ||
@@ -672,0 +672,0 @@ Please see the [following documentation](docs/typescript.md) for information |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
102194
0