flora-errors
Advanced tools
Comparing version 2.0.0 to 2.1.0
11
index.js
@@ -59,2 +59,10 @@ 'use strict'; | ||
class GoneError extends FloraError { | ||
constructor(...args) { | ||
super(...args); | ||
this.httpStatusCode = 410; | ||
this.code = 'ERR_GONE'; | ||
} | ||
} | ||
class ImplementationError extends FloraError { | ||
@@ -114,3 +122,3 @@ constructor(...args) { | ||
if (err.info) { | ||
Object.keys(err.info).forEach(key => { | ||
Object.keys(err.info).forEach((key) => { | ||
if ( | ||
@@ -133,2 +141,3 @@ !Object.prototype.hasOwnProperty.call(error, key) && | ||
NotFoundError, | ||
GoneError, | ||
ImplementationError, | ||
@@ -135,0 +144,0 @@ DataError, |
{ | ||
"name": "flora-errors", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Error definitions for Flora", | ||
@@ -36,11 +36,11 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.0.1", | ||
"eslint-config-prettier": "^6.0.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"mocha": "^6.1.4", | ||
"@types/chai": "^4.2.22", | ||
"chai": "^4.3.4", | ||
"eslint": "^7.18.0", | ||
"eslint-config-prettier": "^7.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"mocha": "^8.2.1", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^1.18.2" | ||
"prettier": "^2.4.1" | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
# Flora Errors | ||
# flora-errors | ||
[![Build Status](https://travis-ci.org/godmodelabs/flora-errors.svg?branch=master)](https://travis-ci.org/godmodelabs/flora-errors) | ||
[![NPM version](https://badge.fury.io/js/flora-errors.svg)](https://www.npmjs.com/package/flora-errors) | ||
[![Dependencies](https://img.shields.io/david/godmodelabs/flora-errors.svg)](https://david-dm.org/godmodelabs/flora-errors) | ||
![](https://github.com/godmodelabs/flora-errors/workflows/ci/badge.svg) | ||
[![NPM version](https://img.shields.io/npm/v/flora-errors.svg?style=flat)](https://www.npmjs.com/package/flora-errors) | ||
[![NPM downloads](https://img.shields.io/npm/dm/flora-errors.svg?style=flat)](https://www.npmjs.com/package/flora-errors) | ||
@@ -17,39 +17,54 @@ Error definitions for [Flora](https://github.com/godmodelabs/flora). | ||
Generic request error (the user made an invalid request). HTTP status code `400`, the `message` will be displayed. | ||
Error code is `ERR_REQUEST_ERROR`. | ||
- Generic request error (the user made an invalid request) | ||
- HTTP status code `400`, the `message` will be displayed | ||
- Error code is `ERR_REQUEST_ERROR` | ||
### AuthenticationError | ||
The user is either not authenticated, or the credentials are wrong. HTTP status code `401`. | ||
Error code is `ERR_AUTHENTICATION_ERROR`. | ||
- The user is either not authenticated, or the credentials are wrong | ||
- HTTP status code `401` | ||
- Error code is `ERR_AUTHENTICATION_ERROR` | ||
### AuthorizationError | ||
The user may be authenticated, but is not authorized for the requested action. HTTP status code `403`. | ||
Error code is `ERR_AUTHORIZATION_ERROR`. | ||
- The user may be authenticated, but is not authorized for the requested action | ||
- HTTP status code `403` | ||
- Error code is `ERR_AUTHORIZATION_ERROR` | ||
### NotFoundError | ||
Either the requested resource could not be found, or a specific entity of the resource. HTTP status code `404`, `message` will be displayed. | ||
Error code is `ERR_NOT_FOUND`. | ||
- Either the requested resource could not be found, or a specific entity of the resource. | ||
- HTTP status code `404`, `message` will be displayed | ||
- Error code is `ERR_NOT_FOUND` | ||
### GoneError | ||
- The requested resource is gone, e.g. was deleted | ||
- HTTP status code `410`, `message` will be displayed | ||
- Error code is `ERR_GONE` | ||
### ImplementationError | ||
There is a problem with the implementation, e.g. of one of the resources. This should not happen. HTTP status code `500`. | ||
Error code is `ERR_IMPLEMENTATION_ERROR`. | ||
- There is a problem with the implementation, e.g. of one of the resources. This should not happen | ||
- HTTP status code `500` | ||
- Error code is `ERR_IMPLEMENTATION_ERROR` | ||
### DataError | ||
There is a problem with the data retrieved by one of the data sources. HTTP status code `500`. | ||
Error code is `ERR_DATA_ERROR`. | ||
- There is a problem with the data retrieved by one of the data sources | ||
- HTTP status code `500` | ||
- Error code is `ERR_DATA_ERROR` | ||
### ConnectionError | ||
There is a problem with the connection to a data source. May work on retry (e.g. temporary network problems). HTTP status code `503`. | ||
Error code is `ERR_CONNECTION_ERROR`. | ||
- There is a problem with the connection to a data source. May work on retry (e.g. temporary network problems) | ||
- HTTP status code `503`. | ||
- Error code is `ERR_CONNECTION_ERROR` | ||
### ValidationError | ||
There is a problem validating input data. This is a special case of `RequestError`. HTTP status code `400`. | ||
Error code is `ERR_VALIDATION_ERROR`. Second parameter of constructor will be added as additional `validation` property. | ||
- There is a problem validating input data. This is a special case of `RequestError` | ||
- HTTP status code `400` | ||
- Error code is `ERR_VALIDATION_ERROR` | ||
- Second parameter of constructor will be added as additional `validation` property. | ||
@@ -56,0 +71,0 @@ ## License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8411
125
73
7