A JavaScript error library to make easier, faster and practical the stack of errors.
Throw this error if it is a body property error.
import { BodyPropertyError } from 'errors-stack';
throw new BodyPropertyError('message');
Throw this error if it is a forbidden error.
import { ForbiddenError } from 'errors-stack';
throw new ForbiddenError('message');
Throw this error if it is a health error.
import { HealthError } from 'errors-stack';
throw new HealthError('message');
Throw this error if it is a internal server error.
import { InternalServiceError } from 'errors-stack';
throw new InternalServiceError('message');
Throw this error if it is a not found error.
import { NotFoundError } from 'errors-stack';
throw new NotFoundError('message');
Throw this error if it is a param error.
import { ParamPropertyError } from 'errors-stack';
throw new ParamPropertyError('message');
Throw this error if it is a query error.
import { QueryPropertyError } from 'errors-stack';
throw new QueryPropertyError('message');
Throw this error if has many requests.
import { TooManyRequestsError } from 'errors-stack';
throw new TooManyRequestsError('message');
Throw this error if has unauthorized situation.
import { UnauthorizedError } from 'errors-stack';
throw new UnauthorizedError({ message: 'message', status: 401 });
Throw this error if error is unknown.
import { UnknownError } from 'errors-stack';
throw new UnknownError({ message: 'message', status: 401 });
Throw this error if is an validation error, and array is necessary to throw this error.
import { ValidationError } from 'errors-stack';
throw new ValidationError({
message: 'message',
validations: [new BodyPropertyError('message')],
});
You can instance new error, with name and params and throw when is necessary
import { ErrorsStack } from 'errors-stack'
const MyError = ErrorsStack({
name: 'MyError',
message: 'My default message',
})
throw new MyError({
message: 'My personalized message',
status: 500,
errorParams: { isAuthenticated: false },
})
errors-stack is freely distributable under the terms of MIT License.