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 operationInProgress(msg) {
            return new Errors(ErrorCode.OperationInProgress, msg);
        }
        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["OperationInProgress"] = "ComProtocolOperationInProgress";
    })(ErrorCode = ComProtocol.ErrorCode || (ComProtocol.ErrorCode = {}));
})(ComProtocol || (ComProtocol = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tLXByb3RvY29sLmludGVyZmFjZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3Byb3RvY29sL2FwaS9zcmMvbGliL2NvbS1wcm90b2NvbC5pbnRlcmZhY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBcUVBLE1BQU0sS0FBVyxXQUFXLENBcUUzQjtBQXJFR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