Annotation of libwww/Library/src/HTError.html, revision 2.44
2.1 frystyk 1: <HTML>
2: <HEAD>
2.40 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 4-Jul-1996 -->
2.43 frystyk 4: <TITLE>W3C Sample Code Library libwww Error Class</TITLE>
2.1 frystyk 5: </HEAD>
6: <BODY>
2.37 frystyk 7: <H1>
8: The Error Class
9: </H1>
2.18 frystyk 10: <PRE>
11: /*
2.22 frystyk 12: ** (c) COPYRIGHT MIT 1995.
2.18 frystyk 13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.37 frystyk 16: <P>
17: The Error class provides an easy API for registering errors ocurring while
18: the Library serves a request. All errors are registered in an "error
19: stack" in the <A HREF="HTReq.html">Request object</A> which allows for
20: nested errors. The Error class is both natural language independent and
21: application independent in that it uses enumerations in order to refer to
22: specific errors. It is for the application to provide an error presentation
23: module which interprets the errors associated with a request. An eample of
24: such an implementation can be found in the <A HREF="HTDialog.html">HTDialog
25: module</A>.
26: <P>
27: This module is implemented by <A HREF="HTError.c">HTError.c</A>, and it is
2.43 frystyk 28: a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Sample Code
2.37 frystyk 29: Library</A>.
2.1 frystyk 30: <PRE>
31: #ifndef HTERROR_H
32: #define HTERROR_H
2.36 frystyk 33:
34: typedef struct _HTError HTError;
35:
36: typedef enum _HTSeverity {
37: ERR_UNKNOWN = 0x0,
38: ERR_FATAL = 0x1,
39: ERR_NON_FATAL = 0x2,
40: ERR_WARN = 0x4,
41: ERR_INFO = 0x8
42: } HTSeverity;
43:
2.28 frystyk 44: #include "HTReq.h"
2.1 frystyk 45: </PRE>
2.37 frystyk 46: <H2>
47: <A NAME="errorinfo">Error Codes and Messages</A>
48: </H2>
49: <P>
50: <B>Note:</B> All non-HTTP error codes have index numbers > HTERR_HTTP_CODES,
51: and they will not be shown in the error-message generated.
2.1 frystyk 52: <PRE>
53: typedef enum _HTErrorElement {
2.38 frystyk 54: HTERR_CONTINUE = 0, /* 100 */
55: HTERR_SWITCHING, /* 101 */
56: HTERR_OK, /* 200 */
2.1 frystyk 57: HTERR_CREATED, /* 201 */
58: HTERR_ACCEPTED, /* 202 */
2.38 frystyk 59: HTERR_NON_AUTHORITATIVE, /* 203 */
2.23 frystyk 60: HTERR_NO_CONTENT, /* 204 */
2.38 frystyk 61: HTERR_RESET, /* 205 */
62: HTERR_PARTIAL, /* 206 */
63: HTERR_MULTIPLE, /* 300 */
2.1 frystyk 64: HTERR_MOVED, /* 301 */
65: HTERR_FOUND, /* 302 */
66: HTERR_METHOD, /* 303 */
67: HTERR_NOT_MODIFIED, /* 304 */
2.38 frystyk 68: HTERR_USE_PROXY, /* 305 */
2.1 frystyk 69: HTERR_BAD_REQUEST, /* 400 */
70: HTERR_UNAUTHORIZED, /* 401 */
71: HTERR_PAYMENT_REQUIRED, /* 402 */
72: HTERR_FORBIDDEN, /* 403 */
73: HTERR_NOT_FOUND, /* 404 */
2.20 frystyk 74: HTERR_NOT_ALLOWED, /* 405 */
75: HTERR_NONE_ACCEPTABLE, /* 406 */
2.38 frystyk 76: HTERR_PROXY_UNAUTHORIZED, /* 407 */
2.20 frystyk 77: HTERR_TIMEOUT, /* 408 */
2.38 frystyk 78: HTERR_CONFLICT, /* 409 */
79: HTERR_GONE, /* 410 */
80: HTERR_LENGTH_REQUIRED, /* 411 */
81: HTERR_PRECON_FAILED, /* 412 */
82: HTERR_TOO_BIG, /* 413 */
83: HTERR_URI_TOO_BIG, /* 414 */
84: HTERR_UNSUPPORTED, /* 415 */
2.1 frystyk 85: HTERR_INTERNAL, /* 500 */
86: HTERR_NOT_IMPLEMENTED, /* 501 */
2.20 frystyk 87: HTERR_BAD_GATE, /* 502 */
88: HTERR_DOWN, /* 503 */
89: HTERR_GATE_TIMEOUT, /* 504 */
2.38 frystyk 90: HTERR_BAD_VERSION, /* 505 */
91:
92: /* Cache warnings */
93: HTERR_STALE, /* 10 */
94: HTERR_REVALIDATION_FAILED, /* 11 */
95: HTERR_DISCONNECTED_CACHE, /* 12 */
96: HTERR_HEURISTIC_EXPIRATION, /* 13 */
97: HTERR_TRANSFORMED, /* 14 */
98: HTERR_CACHE, /* 99 */
99:
100: /* Put all non-HTTP status codes after this */
2.1 frystyk 101: HTERR_NO_REMOTE_HOST,
2.13 frystyk 102: HTERR_NO_HOST,
2.31 frystyk 103: HTERR_NO_FILE,
2.1 frystyk 104: HTERR_FTP_SERVER,
105: HTERR_FTP_NO_RESPONSE,
106: HTERR_TIME_OUT,
2.2 frystyk 107: HTERR_GOPHER_SERVER,
108: HTERR_INTERRUPTED,
2.13 frystyk 109: HTERR_CON_INTR,
2.2 frystyk 110: HTERR_CSO_SERVER,
2.20 frystyk 111: HTERR_HTTP09,
112: HTERR_BAD_REPLY,
2.16 frystyk 113: HTERR_UNKNOWN_AA,
2.5 frystyk 114: HTERR_NEWS_SERVER,
2.7 frystyk 115: HTERR_FILE_TO_FTP,
2.39 frystyk 116: HTERR_AUTO_REDIRECT,
2.8 frystyk 117: HTERR_MAX_REDIRECT,
2.16 frystyk 118: HTERR_EOF,
2.14 frystyk 119: HTERR_WAIS_OVERFLOW,
120: HTERR_WAIS_MODULE,
2.12 frystyk 121: HTERR_WAIS_NO_CONNECT,
2.2 frystyk 122: HTERR_SYSTEM,
2.29 frystyk 123: HTERR_CLASS,
2.31 frystyk 124: HTERR_ACCESS,
125: HTERR_LOGIN,
2.41 frystyk 126: HTERR_CACHE_EXPIRED,
2.44 ! frystyk 127: HTERR_NO_AUTO_RULES,
! 128: HTERR_NO_AUTO_PROXY,
2.1 frystyk 129: HTERR_ELEMENTS /* This MUST be the last element */
130: } HTErrorElement;
2.30 frystyk 131: </PRE>
2.37 frystyk 132: <H2>
133: What Errors should be Parsed Through?
134: </H2>
135: <P>
136: This variable dictates which errors should be put out when generating the
137: message to the user. The first four enumerations make it possible to see
138: `everything as bad or worse than' this level, e.g. <CODE>HT_ERR_SHOW_NON_FATAL
139: </CODE>shows messages of type <CODE>HT_ERR_SHOW_NON_FATAL </CODE>and
140: <CODE>HT_ERR_SHOW_FATAL</CODE>.
141: <P>
142: <B>Note:</B> The default value is made so that it only puts a message to
143: <EM>stderr</EM> if a `real' error has occurred. If a separate widget is available
144: for information and error messages then probably
145: <CODE>HT_ERR_SHOW_DETAILED</CODE> would be more appropriate.
146: <PRE>
147: typedef enum _HTErrorShow {
148: HT_ERR_SHOW_FATAL = 0x1,
149: HT_ERR_SHOW_NON_FATAL = 0x3,
150: HT_ERR_SHOW_WARNING = 0x7,
151: HT_ERR_SHOW_INFO = 0xF,
152: HT_ERR_SHOW_PARS = 0x10,
153: HT_ERR_SHOW_LOCATION = 0x20,
154: HT_ERR_SHOW_IGNORE = 0x40,
155: HT_ERR_SHOW_FIRST = 0x80,
156: HT_ERR_SHOW_LINKS = 0x100,
157: HT_ERR_SHOW_DEFAULT = 0x13,
158: HT_ERR_SHOW_DETAILED = 0x1F,
159: HT_ERR_SHOW_DEBUG = 0x7F
160: } HTErrorShow;
2.19 roeber 161:
2.42 eric 162: typedef struct _HTErrorMessage {
163: int code; /* Error number */
164: char * msg; /* Short explanation */
165: char * url; /* Explaning URL */
166: } HTErrorMessage;
167:
168: /* CODE ERROR MESSAGE ERROR URL */
169: #define HTERR_ENGLISH_INITIALIZER \
170: { 100, "Continue", "information" }, \
171: { 101, "Switching Protocols", "information" }, \
172: { 200, "OK", "success" }, \
173: { 201, "Created", "success" }, \
174: { 202, "Accepted", "success" }, \
175: { 203, "Non-authoritative Information", "success" }, \
176: { 204, "No Content", "success" }, \
177: { 205, "Reset Content", "success" }, \
178: { 206, "Partial Content", "success" }, \
179: { 300, "Multiple Choices", "redirection" }, \
180: { 301, "Moved Permanently", "redirection" }, \
181: { 302, "Moved Temporarily", "redirection" }, \
182: { 303, "See Other", "redirection" }, \
183: { 304, "Not Modified", "redirection" }, \
184: { 305, "Use Proxy", "redirection" }, \
185: { 400, "Bad Request", "client_error" }, \
186: { 401, "Unauthorized", "client_error" }, \
187: { 402, "Payment Required", "client_error" }, \
188: { 403, "Forbidden", "client_error" }, \
189: { 404, "Not Found", "client_error" }, \
190: { 405, "Method Not Allowed", "client_error" }, \
191: { 406, "Not Acceptable", "client_error" }, \
192: { 407, "Proxy Authentication Required", "client_error" }, \
193: { 408, "Request Timeout", "client_error" }, \
194: { 409, "Conflict", "client_error" }, \
195: { 410, "Gone", "client_error" }, \
196: { 411, "Length Required", "client_error" }, \
197: { 412, "Precondition Failed", "client_error" }, \
198: { 413, "Request Entity Too Large", "client_error" }, \
199: { 414, "Request-URI Too Large", "client_error" }, \
200: { 415, "Unsupported Media Type", "client_error" }, \
201: { 500, "Internal Server Error", "server_error" }, \
202: { 501, "Not Implemented", "server_error" }, \
203: { 502, "Bad Gateway", "server_error" }, \
204: { 503, "Service Unavailable", "server_error" }, \
205: { 504, "Gateway Timeout", "server_error" }, \
206: { 505, "HTTP Version not supported", "server_error" }, \
207: \
208: /* Cache Warnings */ \
209: { 10, "Response is Stale", "cache" }, \
210: { 11, "Revalidation Failed", "cache" }, \
211: { 12, "Disconnected Opeartion", "cache" }, \
212: { 13, "Heuristic Expiration", "cache" }, \
213: { 14, "Transformation Applied", "cache" }, \
214: { 99, "Cache warning", "cache" }, \
215: \
216: /* Non-HTTP Error codes and warnings */ \
217: { 0, "Can't locate remote host", "internal" }, \
218: { 0, "No host name found", "internal" }, \
219: { 0, "No file name found or file not accessible", "internal" }, \
220: { 0, "FTP-server replies", "internal" }, \
221: { 0, "FTP-server doesn't reply", "internal" }, \
222: { 0, "Server timed out", "internal" }, \
223: { 0, "Gopher-server replies", "internal" }, \
224: { 0, "Data transfer interrupted", "internal" }, \
225: { 0, "Connection establishment interrupted", "internal" }, \
226: { 0, "CSO-server replies", "internal" }, \
227: { 0, "This is probably a HTTP server 0.9 or less","internal" }, \
228: { 0, "Bad, Incomplete, or Unknown Response", "internal" }, \
229: { 0, "Unknown access authentication scheme", "internal" }, \
230: { 0, "News-server replies", "internal" }, \
231: { 0, "Trying `ftp://' instead of `file://'", "internal" }, \
232: { 0, "Too many redirections", "internal" }, \
233: { 0, "Method not suited for automatic redirection","internal" }, \
234: { 0, "Premature End Of File", "internal" }, \
235: { 0, "Response from WAIS Server too Large - Extra lines \
236: ignored","internal"}, \
237: { 0, "WAIS-server doesn't return any data", "internal" }, \
238: { 0, "Can't connect to WAIS-server", "internal" }, \
239: { 0, "System replies", "internal" }, \
240: { 0, "Wrong or unknown access scheme", "internal" }, \
241: { 0, "Access scheme not allowed in this context", "internal" }, \
242: { 0, "When you are connected, you can log in", "internal" }, \
2.44 ! frystyk 243: { 0, "This version has expired and will be automatically reloaded", "internal" }, \
! 244: { 0, "Loading new rules must be explicitly acknowledged", "internal" }, \
! 245: { 0, "Automatic proxy redirection must be explicitly acknowledged", "internal" }
2.42 eric 246:
2.44 ! frystyk 247:
2.37 frystyk 248: extern HTErrorShow HTError_show (void);
249: extern BOOL HTError_setShow (HTErrorShow mask);
250: </PRE>
251: <H2>
252: Creation and Deletion Methods
253: </H2>
254: <H3>
255: Add an Error
256: </H3>
257: <P>
258: Add an error message to the error list. `par' and `where' might be set to
259: NULL. If par is a string, it is sufficient to let length be unspecified,
260: i.e., 0. If only a part of the string is wanted then specify a length inferior
261: to strlen((char *) par). The string is '\0' terminated automaticly. See also
262: HTError_addSystem for system errors. Returns YES if OK, else NO.
2.30 frystyk 263: <PRE>
264: extern BOOL HTError_add (HTList * list,
265: HTSeverity severity,
266: BOOL ignore,
267: int element,
268: void * par,
269: unsigned int length,
270: char * where);
271:
272: </PRE>
2.37 frystyk 273: <H3>
274: Add a System Error
275: </H3>
276: <P>
277: Add a system error message to the error list. syscall is the name of the
278: system call, e.g. "close". The message put to the list is that corresponds
279: to the error number passed. See also HTError_add. Returns YES if OK, else
280: NO.
2.30 frystyk 281: <PRE>
282: extern BOOL HTError_addSystem (HTList * list,
283: HTSeverity severity,
284: int errornumber,
285: BOOL ignore,
286: char * syscall);
287: </PRE>
2.37 frystyk 288: <H3>
289: Delete an Entire Error Stack
290: </H3>
291: <P>
2.30 frystyk 292: Deletes all errors in a list.
293: <PRE>
294: extern BOOL HTError_deleteAll (HTList * list);
2.1 frystyk 295: </PRE>
2.37 frystyk 296: <H3>
297: Deletes the Last Edded Entry
298: </H3>
299: <P>
2.30 frystyk 300: Deletes the last error entry added to the list. Return YES if OK, else NO
301: <PRE>
302: extern BOOL HTError_deleteLast (HTList * list);
303: </PRE>
2.37 frystyk 304: <H2>
2.40 frystyk 305: Object Methods
2.37 frystyk 306: </H2>
307: <H3>
308: Show the Error Entry?
309: </H3>
310: <P>
2.30 frystyk 311: Should we show this entry in the list or just continue to the next one?
2.1 frystyk 312: <PRE>
2.30 frystyk 313: extern BOOL HTError_doShow (HTError * info);
2.1 frystyk 314: </PRE>
2.37 frystyk 315: <H3>
316: Ignore last Added Error
317: </H3>
318: <P>
319: Turns on the `ignore' flag for the most recent error entered the error list.
320: Returns YES if OK else NO
2.1 frystyk 321: <PRE>
2.30 frystyk 322: extern BOOL HTError_ignoreLast (HTList * list);
323: extern BOOL HTError_setIgnore (HTError * info);
2.2 frystyk 324: </PRE>
2.37 frystyk 325: <H3>
326: Error Index Number
327: </H3>
328: <P>
329: Each error object is assigned an index number as defined by the
330: <CODE>HTErrorElement</CODE> above. The mapping from this index to an error
331: code and a message must be done by the application. The Library provides
332: a default implementation in the <A HREF="HTDialog.html"> HTDialog module</A>,
333: but that can of course be changed depending on the application.
2.15 frystyk 334: <PRE>
2.31 frystyk 335: extern int HTError_index (HTError * info);
2.37 frystyk 336: </PRE>
337: <H3>
338: Error Severity
339: </H3>
2.40 frystyk 340: <P>
341: This function returns the severity of the error object passed by the caller
342: <PRE>extern HTSeverity HTError_severity (HTError * info);
343: </PRE>
344: <P>
345: You can ask whether a list of errors contains any error object with a severity
346: level which is higher than the one specifed.
347: <PRE>extern BOOL HTError_hasSeverity (HTList * list, HTSeverity severity);
2.37 frystyk 348: </PRE>
349: <H3>
350: Parameters Asscotiated with Error
351: </H3>
352: <PRE>
2.30 frystyk 353: extern void * HTError_parameter (HTError * info, int * length);
2.37 frystyk 354: </PRE>
355: <H3>
356: Where did it happen?
357: </H3>
358: <PRE>
2.34 frystyk 359: extern const char * HTError_location (HTError * info);
2.1 frystyk 360: </PRE>
361: <PRE>
362: #endif
363: </PRE>
2.37 frystyk 364: <P>
365: <HR>
2.36 frystyk 366: <ADDRESS>
2.44 ! frystyk 367: @(#) $Id: HTError.html,v 2.43 1997/02/16 18:42:10 frystyk Exp $
2.36 frystyk 368: </ADDRESS>
2.37 frystyk 369: </BODY></HTML>
Webmaster