Hata (HTTP Errors)
Common HTTP errors to be used with express.js or whatever engine you use.
Hata means "error" in Arabic (and Turkish!), which is where the package name comes from.
The following error types are currently supported:
- (400) bad-request:
- (401) unauthorized:
- (403) forbidden:
- (404) not-found:
- (409) conflict:
- (422) unprocessable-entity:
The error object is an instance of
Error, with the properties
var NotFoundError = ;throw 'Product not found';
You can also add more properties to the error object by passing them as the second parameter.
var NotFoundError = ;var error = 'Product not found' item: 'product' id: 1 ;// error now has attributes `item` and `id`.
You can also use it in the following way:
var hata = ;var error = ;
Just add a regular error handler like the following: