camstreamerlib
Version:
Helper library for CamStreamer ACAP applications.
177 lines (176 loc) • 5.29 kB
JavaScript
export class ErrorWithResponse extends Error {
res;
constructor(res) {
super(res.statusText);
this.res = res;
this.name = 'ErrorWithResponse';
}
}
export class ServiceUnavailableError extends Error {
constructor() {
super('Service is unavailable.');
this.name = 'ServiceUnavailableError';
}
}
export class ServiceNotFoundError extends Error {
constructor() {
super('Service not found.');
this.name = 'ServiceNotFoundError';
}
}
export class ParsingBlobError extends Error {
constructor(err) {
super('Error parsing response as Blob: ' + err);
this.name = 'ParsingBlobError';
}
}
export class JsonParseError extends Error {
constructor(paramName, data) {
super(`Error: in JSON parsing of ${paramName}. Cannot parse: ${data}`);
this.name = 'JsonParseError';
}
}
export class ParameterNotFoundError extends Error {
constructor(paramName) {
super(`Error: no parameter '${paramName}' was found`);
this.name = 'ParameterNotFoundError';
}
}
export class SettingParameterError extends Error {
constructor(message) {
super(`Error setting parameter to camera: ${message}`);
this.name = 'SettingParameterError';
}
}
export class ApplicationAPIError extends Error {
action;
constructor(action, reason) {
super(`Error performing application action '${action}': ${reason}`);
this.action = action;
this.name = 'ApplicationAPIError';
}
}
export class SDCardActionError extends Error {
action;
constructor(action, reason) {
super(`Error performing SD card action '${action}': ${reason}`);
this.action = action;
this.name = 'SDCardActionError';
}
}
export class SDCardJobError extends Error {
constructor(reason) {
super(`Error while fetching SD card job progress: ${reason}`);
this.name = 'SDCardJobError';
}
}
const MAX_FPS_ERROR_MESSAGES = {
MALFORMED_REPLY: 'Malformed reply from camera',
CHANNEL_NOT_FOUND: 'Video channel not found.',
CAPTURE_MODE_NOT_FOUND: 'No enabled capture mode found.',
FPS_NOT_SPECIFIED: 'Max fps not specified for given capture mode.',
};
export class MaxFPSError extends Error {
constructor(state) {
super(`[MAX_FPS ${state}] Error: ` + MAX_FPS_ERROR_MESSAGES[state]);
this.name = 'MaxFPSError';
}
}
export class NoDeviceInfoError extends Error {
constructor() {
super('Did not get any data from remote camera');
this.name = 'NoDeviceInfoError';
}
}
export class FetchDeviceInfoError extends Error {
constructor(err) {
super('Error fetching remote camera data: ' + err);
this.name = 'NoDeviceInfoFromCameraError';
}
}
export class AddNewClipError extends Error {
constructor(message) {
super('Error adding new clip: ' + message);
this.name = 'AddNewClipError';
}
}
export class PtzNotSupportedError extends Error {
constructor() {
super('Ptz not supported.');
this.name = 'PtzNotSupportedError';
}
}
export class StorageDataFetchError extends Error {
constructor(err) {
super('Error fetching storage data: ' + err);
this.name = 'StorageDataFetchError';
}
}
export class WsAuthorizationError extends Error {
constructor(message) {
super('Server error on ws authorization: ' + message);
this.name = 'WsAuthorizationError';
}
}
export class UtcTimeFetchError extends Error {
constructor(message) {
super('Server error on get UTC time: ' + message);
this.name = 'UtcTimeFetchError';
}
}
export class TimezoneNotSetupError extends Error {
constructor() {
super('Time zone not setup on the device');
this.name = 'TimezoneNotSetupError';
}
}
export class TimezoneFetchError extends Error {
constructor(err) {
super('Error fetching time zone information: ' + err);
this.name = 'TimezoneFetchError';
}
}
export class ResetCalibrationError extends ErrorWithResponse {
type;
constructor(type, res) {
super(res);
this.type = type;
this.name = 'ResetCalibrationError';
}
}
export class ImportSettingsError extends ErrorWithResponse {
constructor(res) {
super(res);
this.name = 'ImportSettingsError';
}
}
export class CannotSetCoordsInAutoModeError extends Error {
constructor() {
super("The automatic mode doesn't allow control of the camera.");
this.name = 'CannotSetCoordsInAutoModeError';
}
}
export class InvalidLatLngError extends Error {
constructor() {
super('The provided latitude or longitude parameters are invalid.');
this.name = 'InvalidLatLngError';
}
}
export class InvalidAltitudeError extends Error {
constructor() {
super('The provided altitude parameter is invalid.');
this.name = 'InvalidAltitudeError';
}
}
export class ServerError extends Error {
constructor() {
super('An internal server error occurred.');
this.name = 'ServerError';
}
}
export class BadRequestError extends ErrorWithResponse {
constructor(res) {
super(res);
this.name = 'BadRequestError';
}
}