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

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

Webmaster