export var ComProtocol;
(function (ComProtocol) {
    class Errors extends Error {
        // 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"
        //     }
        // }
        constructor(code, msg) {
            super(msg);
            this.code = code;
        }
        static operationCanceled() {
            return new Errors(ErrorCode.OperationCancelled, 'Communication protocol operation cancelled');
        }
        static notConnected(info) {
            return new Errors(ErrorCode.ProtocolNotConnected, 'Communication protocol is not connected');
        }
        static timeoutError(info) {
            return new Errors(ErrorCode.TimeoutError, info.msg || 'Communication protocol timeout');
        }
        static unknownError() {
            return new Errors(ErrorCode.UnknownError, 'Unnown communication protocol error');
        }
    }
    ComProtocol.Errors = Errors;
    let 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tLXByb3RvY29sLmludGVyZmFjZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3Byb3RvY29sL2FwaS9zcmMvbGliL2NvbS1wcm90b2NvbC5pbnRlcmZhY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBcUVBLE1BQU0sS0FBVyxXQUFXLENBNkQzQjtBQTdERCxXQUFpQixXQUFXO0lBQzFCLE1BQWEsTUFBTyxTQUFRLEtBQUs7UUFrQy9CLGtEQUFrRDtRQUNsRCxv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