mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Add Not implemented error class (#15938)
This commit is contained in:
parent
69ce44366e
commit
b07fc41d84
@ -1,8 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const createError = require('http-errors');
|
const createError = require('http-errors');
|
||||||
const { NotFoundError, UnauthorizedError, ForbiddenError, PayloadTooLargeError, RateLimitError } =
|
const {
|
||||||
require('@strapi/utils').errors;
|
NotFoundError,
|
||||||
|
UnauthorizedError,
|
||||||
|
ForbiddenError,
|
||||||
|
PayloadTooLargeError,
|
||||||
|
RateLimitError,
|
||||||
|
NotImplementedError,
|
||||||
|
} = require('@strapi/utils').errors;
|
||||||
|
|
||||||
const mapErrorsAndStatus = [
|
const mapErrorsAndStatus = [
|
||||||
{
|
{
|
||||||
@ -25,6 +31,10 @@ const mapErrorsAndStatus = [
|
|||||||
classError: RateLimitError,
|
classError: RateLimitError,
|
||||||
status: 429,
|
status: 429,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
classError: NotImplementedError,
|
||||||
|
status: 501,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const formatApplicationError = (error) => {
|
const formatApplicationError = (error) => {
|
||||||
|
@ -89,6 +89,14 @@ class PolicyError extends ForbiddenError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NotImplementedError extends ApplicationError {
|
||||||
|
constructor(message, details) {
|
||||||
|
super(message, details);
|
||||||
|
this.name = 'NotImplementedError';
|
||||||
|
this.message = message || 'This feature is not implemented yet';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
HttpError,
|
HttpError,
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
@ -101,4 +109,5 @@ module.exports = {
|
|||||||
RateLimitError,
|
RateLimitError,
|
||||||
PayloadTooLargeError,
|
PayloadTooLargeError,
|
||||||
PolicyError,
|
PolicyError,
|
||||||
|
NotImplementedError,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user