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 {
  public constructor(eno: Errors, msg: string = '') {
    super(`${messages[eno]}.${msg ? ` ${msg}` : ''}`);
  }
}
