Beispiel #1
0
        private void CheckErrorCodeAndThrow(int errorCode)
        {
            string message;

            switch (errorCode)
            {
            case Yaz.ZoomErrorNone:
                break;

            case Yaz.ZoomErrorConnect:
                message = $"Connection could not be made to {_host}:{_port}";
                throw new ConnectionUnavailableException(message);

            case Yaz.ZoomErrorInvalidQuery:
                message = "The query requested is not valid or not supported";
                throw new InvalidQueryException(message);

            case Yaz.ZoomErrorInit:
                message = $"Server {_host}:{_port} rejected our init request";
                throw new InitRejectedException(message);

            case Yaz.ZoomErrorTimeout:
                message = $"Server {_host}:{_port} timed out handling our request";
                throw new ConnectionTimeoutException(message);

            case Yaz.ZoomErrorMemory:
            case Yaz.ZoomErrorEncode:
            case Yaz.ZoomErrorDecode:
            case Yaz.ZoomErrorConnectionLost:
            case Yaz.ZoomErrorInternal:
            case Yaz.ZoomErrorUnsupportedProtocol:
            case Yaz.ZoomErrorUnsupportedQuery:
                message = Yaz.ZOOM_connection_errmsg(ZConnection);
                throw new ZoomImplementationException("A fatal error occurred in Yaz: " + errorCode + " - " +
                                                      message);

            default:
                var code = (Bib1Diagnostic)errorCode;
                throw new Bib1Exception(code, Enum.GetName(typeof(Bib1Diagnostic), code));
            }
        }