var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        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 extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
export var ComProtocol;
(function (ComProtocol) {
    var Errors = /** @class */ (function (_super) {
        __extends(Errors, _super);
        // private static fromErrorCode(code: ErrorCode) {
        //     return new ComProtocolError(code, ComProtocolError.errorCodeToMessage(code));
        // }
        // public static errorCodeToMessage(code: ErrorCode): string {
        //     switch (code) {
        //         case ErrorCode.ProtocolNotConnected:
        //             return
        //         case ErrorCode.TimeoutError:
        //             return "request timeout";
        //         default:
        //             return "unknown error"
        //     }
        // }
        function Errors(code, msg) {
            var _this = _super.call(this, msg) || this;
            _this.code = code;
            return _this;
        }
        Errors.operationCanceled = function () {
            return new Errors(ErrorCode.OperationCancelled, 'Communication protocol operation cancelled');
        };
        Errors.notConnected = function (info) {
            return new Errors(ErrorCode.ProtocolNotConnected, 'Communication protocol is not connected');
        };
        Errors.timeoutError = function (info) {
            return new Errors(ErrorCode.TimeoutError, info.msg || 'Communication protocol timeout');
        };
        Errors.unknownError = function () {
            return new Errors(ErrorCode.UnknownError, 'Unnown communication protocol error');
        };
        return Errors;
    }(Error));
    ComProtocol.Errors = Errors;
    var ErrorCode;
    (function (ErrorCode) {
        ErrorCode["ProtocolNotConnected"] = "ProtocolNotConnected";
        ErrorCode["TimeoutError"] = "TimeoutError";
        ErrorCode["UnknownError"] = "UnknownError";
        ErrorCode["OperationCancelled"] = "OperationCancelled";
    })(ErrorCode = ComProtocol.ErrorCode || (ComProtocol.ErrorCode = {}));
})(ComProtocol || (ComProtocol = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWx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