Exemplo n.º 1
0
        private void CheckErrorCodeAndThrow(int errorCode)
        {
            string message;

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

            case Yaz.ZOOM_ERROR_CONNECT:
                message = string.Format("Connection could not be made to {0}:{1}", _host, _port);
                throw new ConnectionUnavailableException(message);

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

            case Yaz.ZOOM_ERROR_INIT:
                message = string.Format("Server {0}:{1} rejected our init request", _host, _port);
                throw new InitRejectedException(message);

            case Yaz.ZOOM_ERROR_TIMEOUT:
                message = string.Format("Server {0}:{1} timed out handling our request", _host, _port);
                throw new ConnectionTimeoutException(message);

            case Yaz.ZOOM_ERROR_MEMORY:
            case Yaz.ZOOM_ERROR_ENCODE:
            case Yaz.ZOOM_ERROR_DECODE:
            case Yaz.ZOOM_ERROR_CONNECTION_LOST:
            case Yaz.ZOOM_ERROR_INTERNAL:
            case Yaz.ZOOM_ERROR_UNSUPPORTED_PROTOCOL:
            case Yaz.ZOOM_ERROR_UNSUPPORTED_QUERY:
                message = Yaz.ZOOM_connection_errmsg(_zoomConnection);
                throw new ZoomImplementationException("A fatal error occurred in Yaz: " + errorCode + " - " + message);

            default:
                Bib1Diagnostic code = (Bib1Diagnostic)errorCode;
                throw new Bib1Exception(code, Enum.GetName(typeof(Bib1Diagnostic), code));
            }
        }
Exemplo n.º 2
0
 public Bib1Exception(Bib1Diagnostic code, string message)
     : base(message)
 {
     DiagnosticCode = code;
 }