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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tLXByb3RvY29sLmludGVyZmFjZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bpb3RpemUvdGFwL3Byb3RvY29sL2FwaS8iLCJzb3VyY2VzIjpbImxpYi9jb20tcHJvdG9jb2wuaW50ZXJmYWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXFFQSxNQUFNLEtBQVcsV0FBVyxDQTZEM0I7QUE3REQsV0FBaUIsV0FBVztJQUN4QixNQUFhLE1BQU8sU0FBUSxLQUFLO1FBa0M3QixrREFBa0Q7UUFDbEQsb0ZBQW9GO1F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