2019-06-30 01:18:21 +02:00
|
|
|
export const enum Errors {
|
|
|
|
ENOLOGIN = 'ENOLOGIN',
|
|
|
|
ELOGINFAIL = 'ELOGINFAIL',
|
2019-07-26 23:05:29 +02:00
|
|
|
EINITFAIL = 'EINITFAIL',
|
2019-11-18 22:38:51 +01:00
|
|
|
ECOOKIESAVEFAIL = 'ECOOKIESAVEFAIL',
|
2019-06-30 01:18:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = {
|
|
|
|
[Errors.ENOLOGIN]: 'no login form found',
|
|
|
|
[Errors.ELOGINFAIL]: 'login failed',
|
2019-07-26 23:05:29 +02:00
|
|
|
[Errors.EINITFAIL]: 'initialization failed',
|
2019-11-18 22:38:51 +01:00
|
|
|
[Errors.ECOOKIESAVEFAIL]: 'failed to save cookies',
|
2019-06-30 01:18:21 +02:00
|
|
|
};
|
|
|
|
|
2019-07-26 23:05:29 +02:00
|
|
|
export class RenaiError extends Error {
|
2019-12-15 01:14:39 +01:00
|
|
|
public constructor(eno: Errors, msg: string = '') {
|
2019-07-26 23:05:29 +02:00
|
|
|
super(`${messages[eno]}.${msg ? ` ${msg}` : ''}`);
|
2019-06-30 01:18:21 +02:00
|
|
|
}
|
|
|
|
}
|