Download admin-bro/src/backend/utils/errors/validation-error.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/admin-bro/src/backend/utils/errors/validation-error.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/admin-bro/src/backend/utils/errors/validation-error.ts
-
curl -L -o validation-error.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/admin-bro/src/backend/utils/errors/validation-error.ts
1.21 kB
| import { ErrorTypeEnum } from '../../../utils/error-type.enum.js' | |
| import RecordError from './record-error.js' | |
| /** | |
| * Property Errors | |
| * @alias PropertyErrors | |
| * @memberof ValidationError | |
| */ | |
| export type PropertyErrors = { | |
| [key: string]: RecordError; | |
| } | |
| /** | |
| * Error which is thrown when there are validation errors with records | |
| * @category Errors | |
| */ | |
| export class ValidationError extends Error { | |
| /** | |
| * Validation errors for all properties | |
| */ | |
| public propertyErrors: PropertyErrors | |
| /** | |
| * One root validation error i.e. thrown when user wants to perform | |
| * an action which violates foreign key constraint | |
| */ | |
| public baseError: RecordError | null | |
| /** | |
| * HTTP Status code: 400 | |
| */ | |
| public statusCode: number | |
| /** | |
| * @param {PropertyErrors} propertyErrors error messages | |
| * @param {RecordError} [baseError] base error message | |
| */ | |
| constructor(propertyErrors: PropertyErrors, baseError?: RecordError) { | |
| super('Resource cannot be stored because of validation errors') | |
| this.statusCode = 400 | |
| this.propertyErrors = propertyErrors | |
| this.baseError = baseError || null | |
| this.name = ErrorTypeEnum.Validation | |
| } | |
| } | |
| export default ValidationError | |