File size: 1,206 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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
|