File size: 1,313 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 49 50 51 52 53 54 55 |
import { NoticeMessage } from '../../../index.js'
import { ErrorTypeEnum } from '../../../utils/error-type.enum.js'
import RecordError from './record-error.js'
/**
* Error which can be thrown by developer in custom actions/hooks/components
*
* @category Errors
*/
export class AppError extends Error {
/**
* HTTP Status code, defaults to 400
*/
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
/**
* Any additional error information
*/
public data?: Record<string, unknown>
/**
* Any additional notice configuration to show in UI
*/
public notice?: Partial<NoticeMessage>
/**
* @param {string} message a message to be shared with the client
* @param {string} data additional data to be shared with the client
*/
constructor(message: string, data?: Record<string, unknown>, notice?: Partial<NoticeMessage>) {
super(message)
this.statusCode = 400
this.baseMessage = message
this.baseError = {
message,
type: ErrorTypeEnum.App,
}
this.data = data
this.notice = notice
this.name = ErrorTypeEnum.App
}
}
export default AppError
|