@noony-serverless/core
Version:
A Middy base framework compatible with Firebase and GCP Cloud Functions with TypeScript
59 lines • 2.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.TooLargeError = exports.TimeoutError = exports.SecurityError = exports.BusinessError = exports.AuthenticationError = exports.ValidationError = exports.HttpError = void 0;
class HttpError extends Error {
status;
code;
details;
constructor(status, message, code, details) {
super(message);
this.status = status;
this.code = code;
this.details = details;
this.name = 'HttpError';
}
}
exports.HttpError = HttpError;
class ValidationError extends HttpError {
constructor(message, details) {
super(400, message, 'VALIDATION_ERROR', details);
this.name = 'ValidationError';
}
}
exports.ValidationError = ValidationError;
class AuthenticationError extends HttpError {
constructor(message = 'Unauthorized') {
super(401, message, 'AUTHENTICATION_ERROR');
this.name = 'AuthenticationError';
}
}
exports.AuthenticationError = AuthenticationError;
class BusinessError extends HttpError {
constructor(message, status = 500, details) {
super(status, message, 'BUSINESS_ERROR', details);
this.name = 'BusinessError';
}
}
exports.BusinessError = BusinessError;
class SecurityError extends HttpError {
constructor(message = 'Security violation detected', details) {
super(403, message, 'SECURITY_ERROR', details);
this.name = 'SecurityError';
}
}
exports.SecurityError = SecurityError;
class TimeoutError extends HttpError {
constructor(message = 'Request timeout', details) {
super(408, message, 'TIMEOUT_ERROR', details);
this.name = 'TimeoutError';
}
}
exports.TimeoutError = TimeoutError;
class TooLargeError extends HttpError {
constructor(message = 'Request entity too large', details) {
super(413, message, 'TOO_LARGE_ERROR', details);
this.name = 'TooLargeError';
}
}
exports.TooLargeError = TooLargeError;
//# sourceMappingURL=errors.js.map
;