Skip to content

Commit 5f8774e

Browse files
Nethanoseduardoconceicao
authored andcommitted
Add support for Not Implemented error
1 parent 943bf15 commit 5f8774e

File tree

6 files changed

+45
-0
lines changed

6 files changed

+45
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Below is the list of all available errors:
4141
| ForbiddenError | 403 | Forbidden |
4242
| GoneError | 410 | Gone |
4343
| NotFoundError | 404 | Not Found |
44+
| NotImplementedError | 501 | Not Implemented
4445
| ServiceUnavailableError | 503 | Service Unavailable |
4546
| TooManyRequestsError | 429 | Too Many Requests |
4647
| UnauthorizedError | 401 | Unauthorized |

src/errors/not-implemented-error.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
const HttpError = require('./http-error');
8+
9+
/**
10+
* Export "Not Implemented" error.
11+
*/
12+
13+
module.exports = class NotImplementedError extends HttpError {
14+
/**
15+
* Constructor.
16+
*/
17+
18+
constructor() {
19+
super(501, ...arguments);
20+
}
21+
};

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
GoneError: require('./errors/gone-error'),
1313
HttpError: require('./errors/http-error'),
1414
NotFoundError: require('./errors/not-found-error'),
15+
NotImplementedError: require('./errors/not-implemented-error'),
1516
ServiceUnavailableError: require('./errors/service-unavailable-error'),
1617
TooManyRequestsError: require('./errors/too-many-requests-error'),
1718
UnauthorizedError: require('./errors/unauthorized-error'),
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
const { NotImplementedError } = require('../../src');
8+
const test = require('../utils/test-http-error');
9+
10+
/**
11+
* Test "Not Implemented" error.
12+
*/
13+
14+
describe('NotImplementedError', () => {
15+
test(NotImplementedError, 501, 'Not Implemented', false);
16+
});
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { HttpError } from './http-error';
2+
export declare class NotImplementedError extends HttpError {
3+
constructor(message?: string, props?: object);
4+
constructor(props?: object);
5+
}

types/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './errors/forbidden-error';
55
export * from './errors/gone-error';
66
export * from './errors/http-error';
77
export * from './errors/not-found-error';
8+
export * from './errors/not-implemented-error';
89
export * from './errors/service-unavailable-error';
910
export * from './errors/too-many-requests-error';
1011
export * from './errors/unauthorized-error';

0 commit comments

Comments
 (0)