2021-03-11 22:51:58 +01:00
|
|
|
class NoAccessError extends Error {
|
|
|
|
permission: string;
|
|
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
message: string;
|
|
|
|
|
2023-01-20 10:30:20 +01:00
|
|
|
environment?: string;
|
|
|
|
|
|
|
|
constructor(permission: string, environment?: string) {
|
2021-03-11 22:51:58 +01:00
|
|
|
super();
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
|
|
|
|
this.name = this.constructor.name;
|
|
|
|
this.permission = permission;
|
2023-01-20 10:30:20 +01:00
|
|
|
this.environment = environment;
|
|
|
|
if (environment) {
|
|
|
|
this.message = `You need permission=${permission} to perform this action on environment=${environment}`;
|
|
|
|
} else {
|
|
|
|
this.message = `You need permission=${permission} to perform this action`;
|
|
|
|
}
|
2021-03-11 22:51:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON(): any {
|
|
|
|
return {
|
|
|
|
permission: this.permission,
|
|
|
|
message: this.message,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default NoAccessError;
|
|
|
|
module.exports = NoAccessError;
|