Annotation of libwww/Library/src/HTError.html, revision 2.28

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

Webmaster