Comparing version 6.0.0 to 6.0.1
@@ -0,1 +1,8 @@ | ||
## [6.0.1](https://github.com/thenativeweb/defekt/compare/6.0.0...6.0.1) (2020-11-26) | ||
### Bug Fixes | ||
* Add readme section regarding `isError`. ([#224](https://github.com/thenativeweb/defekt/issues/224)) ([ec995da](https://github.com/thenativeweb/defekt/commit/ec995da030e2e3707e3bcb216950d434d26c7189)) | ||
# [6.0.0](https://github.com/thenativeweb/defekt/compare/5.3.0...6.0.0) (2020-11-26) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "defekt", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "defekt is custom errors made simple.", | ||
@@ -30,3 +30,3 @@ "contributors": [ | ||
"assertthat": "5.2.1", | ||
"roboter": "11.5.13", | ||
"roboter": "11.5.14", | ||
"semantic-release-configuration": "1.0.28" | ||
@@ -33,0 +33,0 @@ }, |
@@ -180,2 +180,22 @@ # defekt | ||
### Recognizing JavaScript `Error`s | ||
In addition to `CustomError`s and helpers related to those, `defekt` provides some tooling to work with native JavaScript `Error`s. Since TypeScript 4.0 caught exceptions can be annotated as `unknown` (see [Typescript 4.0 release notes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#unknown-on-catch)). Our [ESLint rules](https://github.com/thenativeweb/eslint-config-es) require us to use `unknown` over `any`, since it is more correct and defensive. | ||
This requires developers to work with type guards to ensure that a caught error is actually an `Error`. Use `isError` for this: | ||
```typescript | ||
import { isError } from 'defekt'; | ||
try { | ||
// ... | ||
} catch (ex: unknown) { | ||
if (!isError(ex)) { | ||
// ex is unfortunately something really weird. You might want to get rid of whatever library is causing this. | ||
throw ex; | ||
} | ||
// ... | ||
} | ||
``` | ||
## Running quality assurance | ||
@@ -182,0 +202,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17837
207