Download src/common/errors/ApiError.js from moustafa7/gymco: direct link, hf CLI and curl.
- Browser
- Download file 750 Bytes
-
https://huggingface.co/spaces/moustafa7/gymco/resolve/main/src/common/errors/ApiError.js
- Command line
-
hf download hf://spaces/moustafa7/gymco/src/common/errors/ApiError.js
-
curl -L -o ApiError.js https://huggingface.co/spaces/moustafa7/gymco/resolve/main/src/common/errors/ApiError.js
750 Bytes
| export class ApiError extends Error { | |
| constructor(statusCode, message, details = undefined) { | |
| super(message); | |
| this.name = 'ApiError'; | |
| this.statusCode = statusCode; | |
| this.details = details; | |
| Error.captureStackTrace?.(this, this.constructor); | |
| } | |
| static badRequest(message, details) { | |
| return new ApiError(400, message, details); | |
| } | |
| static unauthorized(message = 'Authentication required') { | |
| return new ApiError(401, message); | |
| } | |
| static forbidden(message = 'Forbidden') { | |
| return new ApiError(403, message); | |
| } | |
| static notFound(message = 'Resource not found') { | |
| return new ApiError(404, message); | |
| } | |
| static conflict(message = 'Resource already exists') { | |
| return new ApiError(409, message); | |
| } | |
| } | |