export class ApiError extends Error {
    statusCode;
    code;
    constructor(statusCode, code, message) {
        super(message);
        this.statusCode = statusCode;
        this.code = code;
        this.name = "ApiError";
    }
}
export function badRequest(message, code = "bad_request") {
    return new ApiError(400, code, message);
}
export function unauthorized(message = "Non authentifié") {
    return new ApiError(401, "unauthorized", message);
}
export function forbidden(message = "Accès refusé") {
    return new ApiError(403, "forbidden", message);
}
export function notFound(message = "Ressource introuvable") {
    return new ApiError(404, "not_found", message);
}
export function conflict(message, code = "conflict") {
    return new ApiError(409, code, message);
}
//# sourceMappingURL=errors.js.map