All files / lib error.ts

89.83% Statements 53/59
100% Branches 2/2
83.33% Functions 10/12
89.83% Lines 53/59

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 1221x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                   30x   30x 30x                           1x 1x 1x           2x 2x 2x           1x 1x 1x           2x 2x 2x           1x 1x 1x           1x 1x 1x           4x 4x 4x           1x 1x 1x      
export enum ErrorCode {
  unknownError = "unknown_error",
  unknownCommand = "unknown_command",
  invalidCountryCode = "invalid_country_code",
  invalidLanguageCode = "invalid_language_code",
  stationNotFound = "station_not_found",
  stationNotConnected = "station_not_connected",
  stationConnectionTimeout = "station_connection_timeout",
  deviceNotFound = "device_not_found",
  deviceWrongStation = "device_wrong_station",
  deviceInvalidProperty = "device_invalid_property",
  deviceInvalidPropertyValue = "device_invalid_property_value",
  devicePropertyNotSupported = "device_property_not_supported",
  deviceReadOnlyProperty = "device_property_readonly",
  deviceNotSupported = "device_not_supported",
  deviceInvalidCommandValue = "device_invalid_command_value",
  deviceLivestreamAlreadyRunning = "device_livestream_already_running",
  deviceLivestreamNotRunning = "device_livestream_not_running",
  schemaIncompatible = "schema_incompatible",
  deviceDownloadAlreadyRunning = "device_download_already_running",
  deviceDownloadNotRunning = "device_download_not_running",
  deviceOnlyOneDownloadAtATime = "device_only_one_download_at_a_time",
  deviceTalkbackAlreadyRunning = "device_talkback_already_running",
  deviceTalkbackNotRunning = "device_talkback_not_running",
  deviceOnlyOneTalkbackAtATime = "device_only_one_talkback_at_a_time",
  deviceRTSPPropertyNotEnabled = "device_rtsp_property_not_enabled",
}
 
export class BaseError extends Error {
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  errorCode: ErrorCode;
}
 
export class UnknownError extends BaseError {
  errorCode = ErrorCode.unknownError;
 
  constructor(public error: Error) {
    super();
  }
}
 
export class UnknownCommandError extends BaseError {
  errorCode = ErrorCode.unknownCommand;
 
  constructor(public command: string) {
    super();
  }
}
 
export class SchemaIncompatibleError extends BaseError {
  errorCode = ErrorCode.schemaIncompatible;
 
  constructor(public schemaId: number) {
    super();
  }
}
 
export class LivestreamAlreadyRunningError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = LivestreamAlreadyRunningError.name;
  }
}
 
export class LivestreamNotRunningError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = LivestreamNotRunningError.name;
  }
}
 
export class DownloadAlreadyRunningError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = DownloadAlreadyRunningError.name;
  }
}
 
export class DownloadNotRunningError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = DownloadNotRunningError.name;
  }
}
 
export class DownloadOnlyOneAtATimeError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = DownloadOnlyOneAtATimeError.name;
  }
}
 
export class TalkbackAlreadyRunningError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = TalkbackAlreadyRunningError.name;
  }
}
 
export class TalkbackNotRunningError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = TalkbackNotRunningError.name;
  }
}
 
export class TalkbackOnlyOneAtATimeError extends Error {
  constructor(message?: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
    this.name = TalkbackOnlyOneAtATimeError.name;
  }
}