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