@avonjs/avonjs
Version:
A fluent Node.js API generator.
33 lines (32 loc) • 892 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ResponsableException_1 = __importDefault(require("./ResponsableException"));
class AuthenticationException extends ResponsableException_1.default {
error;
constructor(error) {
if (typeof error === 'string') {
super(error);
this.error = new Error(error);
}
else {
super(error?.message ?? 'The user is unauthenticated.');
this.error = error;
}
}
/**
* Get the response code
*/
getCode() {
return 401;
}
/**
* Get the exception name
*/
getName() {
return 'Unauthenticated';
}
}
exports.default = AuthenticationException;