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