Add Not implemented error class (#15938)

This commit is contained in:
DMehaffy 2023-03-21 06:42:45 -07:00 committed by GitHub
parent 69ce44366e
commit b07fc41d84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -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) => {

View File

@ -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,
}; };