Download admin-bro/src/backend/utils/errors/forbidden-error.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 954 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/admin-bro/src/backend/utils/errors/forbidden-error.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/admin-bro/src/backend/utils/errors/forbidden-error.ts
-
curl -L -o forbidden-error.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/admin-bro/src/backend/utils/errors/forbidden-error.ts
954 Bytes
| import { ErrorTypeEnum } from '../../../utils/error-type.enum.js' | |
| import RecordError from './record-error.js' | |
| /** | |
| * Error which is thrown when user | |
| * doesn't have an access to a given resource/action. | |
| * | |
| * @category Errors | |
| */ | |
| export class ForbiddenError extends Error { | |
| /** | |
| * HTTP Status code: 403 | |
| */ | |
| public statusCode: number | |
| /** | |
| * Base error message and type which is stored in the record | |
| */ | |
| public baseError: RecordError | |
| /** | |
| * Any custom message which should be seen in the UI | |
| */ | |
| public baseMessage?: string | |
| /** | |
| * @param {string} [message] | |
| */ | |
| constructor(message?: string) { | |
| const defaultMessage = 'You cannot perform this action' | |
| super(defaultMessage) | |
| this.statusCode = 403 | |
| this.baseMessage = message | |
| this.baseError = { | |
| message: message ?? defaultMessage, | |
| type: ErrorTypeEnum.Forbidden, | |
| } | |
| this.name = ErrorTypeEnum.Forbidden | |
| } | |
| } | |
| export default ForbiddenError | |