Comparing version 1.0.6 to 1.0.7
@@ -0,1 +1,7 @@ | ||
## 1.0.7 - Sat May 16 2020 00:05:10 | ||
**Contributor:** Theo Gravity | ||
- Update readme with use-cases | ||
## 1.0.6 - Fri May 15 2020 23:34:12 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "new-error", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A production-grade error creation and serialization library designed for Typescript", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -24,2 +24,3 @@ # new-error | ||
<!-- TOC --> | ||
- [Motivation / Error handling use-cases](#motivation--error-handling-use-cases) | ||
- [Installation](#installation) | ||
@@ -51,2 +52,19 @@ - [Example Usage](#example-usage) | ||
# Motivation / Error handling use-cases | ||
The basic Javascript `Error` type is extremely bare bones - you can only specify a message. | ||
In a production-level application, I've experienced the following use-cases: | ||
- A developer should be able to add metadata to the error that may assist with troubleshooting. | ||
- A developer should be able to reference the original error. | ||
- Errors should be able to work with a logging framework. | ||
- Errors should be well-formed / have a defined structure that can be consumed / emitted for analytics and services. | ||
- Errors should not expose sensitive data to the end-user / client. | ||
- Errors that are exposed to the end-user / client should not reveal data that would expose system internals. | ||
- Error responses from an API service should follow a common format. | ||
- End-users / clients should be able to relay the error back to support; the relayed data should be enough for a developer to troubleshoot. | ||
`new-error` was built with these use-cases in mind. | ||
# Installation | ||
@@ -496,2 +514,10 @@ | ||
} | ||
// You'll need to modify code below to best fit your use-case | ||
// err.message could potentially expose system internals | ||
return res.json({ | ||
err: { | ||
message: err.message | ||
} | ||
}) | ||
} | ||
@@ -498,0 +524,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
47953
534