@dannybster/expected-errors
v0.7.0
Published
A collection of expected errors that can be raised and middleware for handling/responding to them.
Downloads
14
Readme
expected-errors
A collection of expected errors that can be raised and middleware for handling/responding to them.
Version 0.7.0
- Added #isExternalServiceError.
- Renamed #handleExpectedError to #handleHttpError as it is a better explanation of what it does.
- Added #createExternalServiceError.
- Exported #createHttpError for creating generic expected http errors.
Version 0.6.0
- #createUnauthorizedError now accepts an original error parameter that will be accessible by calling cause() on the error returned from #createUnauthorizedError.
- Unauthorized errors now have the name UnauthorizedError.
- Unauthorized errors now have the message Unauthorized Error.
Version 0.5.0
- handleExpectedError now only sends a response if the headers have not been sent. This is to cater for the use case of an error being raised by a longer running operation that runs on the server but the server has already told the client that everything is ok to aid with performance.
Version 0.4.0
- Updated createNotFoundError to take an error object parameter that will become the cause of not found error returned.
Version 0.3.0
- Added createConflictError.
- Added isConflictError.
Version 0.2.4
- Added the verror dependancy back as it turns out the way verror handles messages is very handy for logging (it concatenates it's causes).
- Added a name property of ServiceUnavailableError to service unavailable errors.
- Added a code property of 503 to service unavailable errors.
Version 0.2.3
- Added the standard bunyan serializers when creating the log object so that error logging provides details, as a side effect req and res objects will also be serialized as per the bunyan standard serializers: https://github.com/trentm/node-bunyan#standard-serializers
Version 0.2.2
- Changed the interface of createServiceUnavailableError to just take a cause
as the thinking is the type of error is descriptive enough. That is any expected error should just be a type wrapper for a cause. Internally it is possible to set a message suce as Service Unavailable Error. - Removed the reliance on verror as the only thing we were using for was the cause function.
- These changes have only been applied to createSericeUnavailableError for now to see how they sit in the context of an application.
Version 0.2.1
- Removed the usage of rewire as it was not needed and made the tests harder to read.
Version 0.2.0
- Added a 503 Service unavailable error.
- Added logError error middleware.
Version 0.1.0
- Added a 404 Not Found error.
- Added a 401 Unauthorized error.
- Added the middleware function handleExpectedError to deal with the above errors.