Files
SerpentRace/SerpentRace_Backend/dist/Application/Services/ErrorResponseService.js
T

32 lines
1.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorResponseService = void 0;
class ErrorResponseService {
static sendError(res, statusCode, message, details) {
const errorResponse = { error: message };
if (details) {
errorResponse.details = details;
}
return res.status(statusCode).json(errorResponse);
}
static sendInternalServerError(res) {
return this.sendError(res, 500, 'Internal server error');
}
static sendBadRequest(res, message = 'Bad request', details) {
return this.sendError(res, 400, message, details);
}
static sendUnauthorized(res, message = 'Unauthorized') {
return this.sendError(res, 401, message);
}
static sendForbidden(res, message = 'Forbidden') {
return this.sendError(res, 403, message);
}
static sendNotFound(res, message = 'Not found') {
return this.sendError(res, 404, message);
}
static sendConflict(res, message = 'Conflict') {
return this.sendError(res, 409, message);
}
}
exports.ErrorResponseService = ErrorResponseService;
//# sourceMappingURL=ErrorResponseService.js.map