Annotation of libwww/Library/src/HTError.html, revision 2.23
2.1 frystyk 1: <HTML>
2: <HEAD>
3: <TITLE>Error message module for libwww</TITLE>
4: <NEXTID N="z1">
5: </HEAD>
6: <BODY>
2.18 frystyk 7:
2.9 frystyk 8: <H1>Reporting Errors and Messages to the Client</H1>
2.1 frystyk 9:
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>
16:
2.15 frystyk 17: This module maintaines a list of error messages that might occur
18: during load of a requested URL. The error list is put out to standard
19: output by a simple function that easily can be overwritten by a smart
2.18 frystyk 20: server or client. <P>
2.15 frystyk 21:
22: <NOTE><B>Note: </B></NOTE> At the moment, <A
2.21 frystyk 23: HREF="HTAlert.c">HTErrorMsg()</A> is called, if the flag
2.15 frystyk 24: HTRequest->error_block is set to YES, then a stream has been put up
25: or taken down in the library and therefore it is <B>VERY</B> unsafe to
2.18 frystyk 26: put anything more to the stream. <P>
27:
28: This module is implemented by <A HREF="HTError.c">HTError.c</A>, and
29: it is a part of the <A
2.21 frystyk 30: HREF="http://www.w3.org/hypertext/WWW/Library/User/Guide/Guide.html">
2.18 frystyk 31: Library of Common Code</A>.
2.4 frystyk 32:
2.1 frystyk 33: <PRE>
34: #ifndef HTERROR_H
35: #define HTERROR_H
2.20 frystyk 36:
2.15 frystyk 37: #include "HTAccess.h"
2.1 frystyk 38: </PRE>
39:
2.3 frystyk 40: <H2>Data Structures</H2>
2.1 frystyk 41:
2.15 frystyk 42: The basic data structure is HTErrorInfo, but in addition the following
43: types are used:
2.1 frystyk 44:
2.3 frystyk 45: <H3>Error Numbers</H3>
2.1 frystyk 46:
2.15 frystyk 47: <NOTE><B>Note: </B></NOTE> All non-HTTP error codes have index numbers
48: > HTERR_HTTP_CODES, and they will not be shown in the error-message
49: generated.
50:
2.1 frystyk 51: <PRE>
52: typedef enum _HTErrorElement {
53: HTERR_OK = 0, /* 200 */
54: HTERR_CREATED, /* 201 */
55: HTERR_ACCEPTED, /* 202 */
56: HTERR_PARTIAL, /* 203 */
2.23 ! frystyk 57: HTERR_NO_CONTENT, /* 204 */
2.1 frystyk 58: HTERR_MOVED, /* 301 */
59: HTERR_FOUND, /* 302 */
60: HTERR_METHOD, /* 303 */
61: HTERR_NOT_MODIFIED, /* 304 */
62: HTERR_BAD_REQUEST, /* 400 */
63: HTERR_UNAUTHORIZED, /* 401 */
64: HTERR_PAYMENT_REQUIRED, /* 402 */
65: HTERR_FORBIDDEN, /* 403 */
66: HTERR_NOT_FOUND, /* 404 */
2.20 frystyk 67: HTERR_NOT_ALLOWED, /* 405 */
68: HTERR_NONE_ACCEPTABLE, /* 406 */
69: HTERR_PROXY, /* 407 */
70: HTERR_TIMEOUT, /* 408 */
2.1 frystyk 71: HTERR_INTERNAL, /* 500 */
72: HTERR_NOT_IMPLEMENTED, /* 501 */
2.20 frystyk 73: HTERR_BAD_GATE, /* 502 */
74: HTERR_DOWN, /* 503 */
75: HTERR_GATE_TIMEOUT, /* 504 */
2.1 frystyk 76: HTERR_HTTP_CODES_END, /* Put all non-HTTP status codes after this */
77: HTERR_NO_REMOTE_HOST,
2.13 frystyk 78: HTERR_NO_HOST,
2.1 frystyk 79: HTERR_FTP_SERVER,
80: HTERR_FTP_NO_RESPONSE,
81: HTERR_TIME_OUT,
2.2 frystyk 82: HTERR_GOPHER_SERVER,
83: HTERR_INTERRUPTED,
2.13 frystyk 84: HTERR_CON_INTR,
2.2 frystyk 85: HTERR_CSO_SERVER,
2.20 frystyk 86: HTERR_HTTP09,
87: HTERR_BAD_REPLY,
2.16 frystyk 88: HTERR_UNKNOWN_AA,
2.5 frystyk 89: HTERR_NEWS_SERVER,
2.7 frystyk 90: HTERR_FILE_TO_FTP,
2.8 frystyk 91: HTERR_MAX_REDIRECT,
2.16 frystyk 92: HTERR_EOF,
2.14 frystyk 93: HTERR_WAIS_OVERFLOW,
94: HTERR_WAIS_MODULE,
2.12 frystyk 95: HTERR_WAIS_NO_CONNECT,
2.2 frystyk 96: HTERR_SYSTEM,
2.1 frystyk 97: HTERR_ELEMENTS /* This MUST be the last element */
98: } HTErrorElement;
2.19 roeber 99:
2.3 frystyk 100: typedef enum _HTErrSeverity {
101: ERR_FATAL = 0x1,
2.7 frystyk 102: ERR_NON_FATAL = 0x2,
2.20 frystyk 103: ERR_WARN = 0x4,
2.7 frystyk 104: ERR_INFO = 0x8
2.3 frystyk 105: } HTErrSeverity;
106:
107: typedef struct _HTErrorInfo {
2.7 frystyk 108: int handle; /* Unique number in this stack */
2.3 frystyk 109: HTErrorElement element; /* Index number into HTErrorMsgInfo */
110: HTErrSeverity severity; /* A la VMS */
111: BOOL ignore; /* YES if msg should not go to user */
112: void * par; /* Explanation, e.g. filename */
113: unsigned int par_length; /* For copying by generic routine */
114: char * where; /* Which function */
115: } HTErrorInfo;
2.1 frystyk 116: </PRE>
117:
2.3 frystyk 118: <H2>Controling Globals</H2>
119:
2.15 frystyk 120: This variable dictates which errors should be put out when generating
121: the message to the user. The first four enumerations make it possible
122: to see `everything as bad or worse than' this level, e.g.
123: HT_ERR_SHOW_NON_FATAL shows messages of type HT_ERR_SHOW_NON_FATAL and
124: HT_ERR_SHOW_FATAL. <P>
125:
126: <B>Note:</B> The default value is made so that it only puts a message
127: to <EM>stderr</EM> if a `real' error has occurred. If a separate
128: widget is available for information and error messages then probably
129: HT_ERR_SHOW_DETAILED would be more appropriate.
2.3 frystyk 130:
131: <PRE>
132: typedef enum _HTErrorShow {
133: HT_ERR_SHOW_FATAL = 0x1,
134: HT_ERR_SHOW_NON_FATAL = 0x3,
135: HT_ERR_SHOW_WARNING = 0x7,
2.6 frystyk 136: HT_ERR_SHOW_INFO = 0xF,
137: HT_ERR_SHOW_PARS = 0x10,
138: HT_ERR_SHOW_LOCATION = 0x20,
139: HT_ERR_SHOW_IGNORE = 0x40,
140: HT_ERR_SHOW_FIRST = 0x80,
2.15 frystyk 141: HT_ERR_SHOW_LINKS = 0x100,
2.7 frystyk 142: HT_ERR_SHOW_DEFAULT = 0x13,
143: HT_ERR_SHOW_DETAILED = 0x1F,
2.10 frystyk 144: HT_ERR_SHOW_DEBUG = 0x7F
2.3 frystyk 145: } HTErrorShow;
146:
147: extern unsigned int HTErrorShowMask;
148: </PRE>
2.1 frystyk 149:
2.15 frystyk 150: This is the table containing the actual error-messages and links for
151: more information:
2.1 frystyk 152:
153: <PRE>
2.3 frystyk 154: typedef struct _HTErrorMsgInfo {
155: int code; /* Error number */
156: char * msg; /* Short explanation */
157: char * url; /* Explaning URL */
158: } HTErrorMsgInfo;
159:
160: extern HTErrorMsgInfo error_info[];
2.1 frystyk 161: </PRE>
162:
2.3 frystyk 163: <H2>Public Error Functions</H2>
164:
2.1 frystyk 165: <H3>Add an Error Message</H3>
166:
167: This function adds an error message to the error_stack list in the HTRequest
2.3 frystyk 168: structure. It always returns a negative value.
2.1 frystyk 169: <PRE>
2.3 frystyk 170: extern int HTErrorAdd PARAMS(( HTRequest * request,
2.1 frystyk 171: HTErrSeverity severity,
172: BOOL ignore,
173: int element,
174: void * par,
175: unsigned int par_length,
176: char * where));
2.2 frystyk 177: </PRE>
178:
179: <H3>Add a System Error Message</H3>
180:
2.15 frystyk 181: This function adds an error from a system call that initializes errno
182: or equivalent and adds it to the error_stack list in the HTRequest
183: structure. It always returns a negative value.
184:
2.2 frystyk 185: <PRE>
2.3 frystyk 186: extern int HTErrorSysAdd PARAMS(( HTRequest * request,
2.2 frystyk 187: HTErrSeverity severity,
2.20 frystyk 188: int errornumber,
2.2 frystyk 189: BOOL ignore,
190: char * syscall));
2.1 frystyk 191: </PRE>
192:
193: <H3>Ignoring an Error Message</H3>
194:
2.15 frystyk 195: If an error message is not to be send to the user, e.g., output to the
196: stream, then the ignore flag must be turn on. Theese functions turns
197: it on for the latest error appended to the list or an arbitrary error
198: refered to by its handle.
199:
2.1 frystyk 200: <PRE>
2.7 frystyk 201: extern void HTErrorIgnore PARAMS((HTRequest * request, int handle));
202: extern void HTErrorIgnoreLast PARAMS((HTRequest * request));
2.1 frystyk 203: </PRE>
204:
2.15 frystyk 205: <H3>Handling Prefix for Links in Error Message</H3>
206:
207: Two functions handle the URL prefix of the links inside the error
208: message. They are quite obvious:
209:
210: <PRE>
2.17 frystyk 211: extern void HTErrorSetPrefix PARAMS((char *path));
212: extern CONST char *HTErrorGetPrefix NOPARAMS;
2.1 frystyk 213: </PRE>
214:
215: <H3>Freeing an Error List</H3>
216:
2.8 frystyk 217: This is normally done when the HTRequest structure is freed but it might be
218: done at any other time in order to ignore a whole series of errors.
2.1 frystyk 219: <PRE>
2.17 frystyk 220: extern void HTErrorFree PARAMS((HTRequest * request));
2.1 frystyk 221: </PRE>
222:
223: <PRE>
224: #endif
225: </PRE>
226: end
227: </BODY>
228: </HTML>
229:
230:
Webmaster