20 lines
505 B
TypeScript
20 lines
505 B
TypeScript
export const enum Errors {
|
|
ENOLOGIN = 'ENOLOGIN',
|
|
ELOGINFAIL = 'ELOGINFAIL',
|
|
EINITFAIL = 'EINITFAIL',
|
|
ECOOKIESAVEFAIL = 'ECOOKIESAVEFAIL',
|
|
}
|
|
|
|
const messages = {
|
|
[Errors.ENOLOGIN]: 'no login form found',
|
|
[Errors.ELOGINFAIL]: 'login failed',
|
|
[Errors.EINITFAIL]: 'initialization failed',
|
|
[Errors.ECOOKIESAVEFAIL]: 'failed to save cookies',
|
|
};
|
|
|
|
export class RenaiError extends Error {
|
|
constructor(eno: Errors, msg: string = '') {
|
|
super(`${messages[eno]}.${msg ? ` ${msg}` : ''}`);
|
|
}
|
|
}
|