File size: 954 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 |
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
|