View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5    *  tags. See the COPYRIGHT.txt in the distribution for a full listing of
6    * individual contributors.
7    *
8    *  All Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  
21  package org.waarp.icap;
22  
23  /**
24   * Standard ICAP error code
25   */
26  public enum IcapError {
27    /**
28     * Cannot connect to ICAP server
29     */
30    ICAP_CANT_CONNECT(1000, "Cannot connect to ICAP server"), // Not used
31    /**
32     * Not used: ICAP Server closed connection while reading response
33     */
34    ICAP_SERVER_RESPONSE_CLOSE(1001,
35                               "ICAP Server closed connection while reading response"),
36    /**
37     * Not used: ICAP Server reset connection while reading response
38     */
39    ICAP_SERVER_RESPONSE_RESET(1002, "ICAP Server reset connection while " +
40                                     "reading response"),
41    /**
42     * ICAP Server sent unknown response code
43     */
44    ICAP_SERVER_UNKNOWN_CODE(1003, "ICAP Server sent unknown response code"),
45    /**
46     * Not used: ICAP Server closed connection on 204 without 'Connection: close' header
47     */
48    ICAP_SERVER_UNEXPECTED_CLOSE_204(1004, "ICAP Server closed connection on " +
49                                           "204 without 'Connection: close' header"),
50    /**
51     * Not used: ICAP Server closed connection as ICAP client wrote body preview
52     */
53    ICAP_SERVER_UNEXPECTED_CLOSE(1005, "ICAP Server closed connection as ICAP " +
54                                       "client wrote body preview"),
55    /**
56     * ICAP Server response missed some information
57     */
58    ICAP_SERVER_MISSING_INFO(1006,
59                             "ICAP Server response missed some information"),
60    /**
61     * Network error during communication with ICAP Server
62     */
63    ICAP_NETWORK_ERROR(1007,
64                       "Network error during communication with ICAP Server"),
65    /**
66     * ICAP Server sends a header without terminator
67     */
68    ICAP_SERVER_HEADER_WITHOUT_TERMINATOR(1008, "ICAP Server sends a header " +
69                                                "without terminator"),
70    /**
71     * ICAP Server sends a too big header
72     */
73    ICAP_SERVER_HEADER_EXCEED_CAPACITY(1009,
74                                       "ICAP Server sends a too big header"),
75    /**
76     * Service is unknown by the ICAP Server
77     */
78    ICAP_SERVER_SERVICE_UNKNOWN(1010, "Service is unknown by the ICAP Server"),
79    /**
80     * ICAP Client has an internal error
81     */
82    ICAP_INTERNAL_ERROR(2000, "ICAP Client has an internal error"),
83    /**
84     * ICAP Client has wrong parameter
85     */
86    ICAP_ARGUMENT_ERROR(2001, "ICAP Client has wrong parameter"),
87    /**
88     * ICAP network operation has a timeout
89     */
90    ICAP_TIMEOUT_ERROR(2002, "ICAP network operation has a timeout"),
91    /**
92     * ICAP Client has a too big file
93     */
94    ICAP_FILE_LENGTH_ERROR(2003, "ICAP Client has a too big file");
95  
96  
97    private final int code;
98    private final String message;
99  
100   IcapError(final int code, final String message) {
101     this.code = code;
102     this.message = message;
103   }
104 
105   public final int getCode() {
106     return code;
107   }
108 
109   public final String getMessage() {
110     return message;
111   }
112 }