"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 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 = exports.ComProtocol || (exports.ComProtocol = {}));
