Comparing version 7.0.2 to 7.0.3
@@ -0,1 +1,8 @@ | ||
## [7.0.3](https://github.com/thenativeweb/defekt/compare/7.0.2...7.0.3) (2021-03-25) | ||
### Bug Fixes | ||
* update examples in README ([#287](https://github.com/thenativeweb/defekt/issues/287)) ([3b2b1ae](https://github.com/thenativeweb/defekt/commit/3b2b1ae0f1f3e1fee0ea53d724f231500fe03528)) | ||
## [7.0.2](https://github.com/thenativeweb/defekt/compare/7.0.1...7.0.2) (2021-03-25) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "defekt", | ||
"version": "7.0.2", | ||
"version": "7.0.3", | ||
"description": "defekt is custom errors made simple.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -191,4 +191,3 @@ # defekt | ||
const configurationResult = await loadConfiguration(); | ||
const configuration = configurationResult.unwrapOrDefault({ port: 3000 }); | ||
const configuration = (await loadConfiguration()).unwrapOrDefault({ port: 3000 }); | ||
@@ -246,13 +245,11 @@ await startServer(configuration.port); | ||
const tokenResult = validateToken('a token'); | ||
const token = validateToken('a token').unwrapOrDefault({ sub: 'anonymous' }); | ||
const token = tokenResult.unwrapOrDefault({ sub: 'anonymous' }); | ||
// Or, if you can't handle the possible errors appropriately and | ||
// instead want to throw the error, possibly crashing your application: | ||
const token = tokenResult.unwrapOrThrow(); | ||
const token = validateToken('a token').unwrapOrThrow(); | ||
// If you want to handle errors by returning a conditional default | ||
// value, you can use `unwrapOrElse` to supply a handler: | ||
const token = tokenResult.unwrapOrElse( | ||
const token = validateToken('a token').unwrapOrElse( | ||
(ex) => { | ||
@@ -259,0 +256,0 @@ switch (ex.code) { |
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
27805
273