UNPKG

@iotize/device-client.js

Version:

IoTize Device client for Javascript

51 lines (50 loc) 2.66 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var format_helper_1 = require("../../core/format/format-helper"); var TapClientError = /** @class */ (function (_super) { __extends(TapClientError, _super); function TapClientError(code, message, cause) { var _this = _super.call(this, message) || this; _this.cause = cause; _this.code = code; return _this; } TapClientError.illegalArgument = function (msg) { return new TapClientError(TapClientError.Code.IllegalArgumentError, msg); }; TapClientError.illegalStateError = function (msg) { return new TapClientError(TapClientError.Code.IllegalStateError, msg); }; TapClientError.encodeRequestError = function (command, cause) { return new TapClientError(TapClientError.Code.EncodeRequestError, "Cannot encode this request: " + command + ". Cause: " + cause, cause); }; TapClientError.decodeResponseError = function (cause, frameOrCommand) { return new TapClientError(TapClientError.Code.DecodeResponseError, "Cannot decode response to command " + (frameOrCommand instanceof Uint8Array ? "0x" + format_helper_1.FormatHelper.toHexString(frameOrCommand) : frameOrCommand.toString()) + ". Cause: " + cause, cause); }; TapClientError.notConnectedError = function () { return new TapClientError(TapClientError.Code.NotConnectedError, 'Trying to execute command but device is not connected'); }; return TapClientError; }(Error)); exports.TapClientError = TapClientError; (function (TapClientError) { var Code; (function (Code) { Code["NotConnectedError"] = "NotConnectedError"; Code["EncodeRequestError"] = "EncodeRequestError"; Code["IllegalArgumentError"] = "IllegalArgumentError"; Code["IllegalStateError"] = "IllegalStateError"; Code["DecodeResponseError"] = "DecodeResponseError"; })(Code = TapClientError.Code || (TapClientError.Code = {})); })(TapClientError = exports.TapClientError || (exports.TapClientError = {})); exports.TapClientError = TapClientError;