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

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.2       frystyk    57:        HTERR_SYSTEM,
2.1       frystyk    58:        HTERR_ELEMENTS                      /* This MUST be the last element */
                     59: } HTErrorElement;
2.3       frystyk    60: 
                     61: typedef enum _HTErrSeverity {
                     62:     ERR_FATAL            = 0x1,
2.7       frystyk    63:     ERR_NON_FATAL        = 0x2,
                     64:     ERR_WARNING          = 0x4,
                     65:     ERR_INFO             = 0x8
2.3       frystyk    66: } HTErrSeverity;
                     67: 
                     68: typedef struct _HTErrorInfo {
2.7       frystyk    69:     int                        handle;         /* Unique number in this stack */
2.3       frystyk    70:     HTErrorElement     element;        /* Index number into HTErrorMsgInfo */
                     71:     HTErrSeverity      severity;       /* A la VMS */
                     72:     BOOL                       ignore;         /* YES if msg should not go to user */
                     73:     void *             par;            /* Explanation, e.g. filename  */
                     74:     unsigned int       par_length;     /* For copying by generic routine */
                     75:     char *             where;          /* Which function */
                     76: } HTErrorInfo;
2.1       frystyk    77: </PRE>
                     78: 
2.3       frystyk    79: <H2>Controling Globals</H2>
                     80: 
2.9     ! frystyk    81: This variable dictates which errors should be put out when generating the
        !            82: message to the user. The first four
2.7       frystyk    83: enumerations make it possible to see `everything as bad or worse than' this
                     84: level, e.g. HT_ERR_SHOW_NON_FATAL shows messages of type HT_ERR_SHOW_NON_FATAL
                     85: and HT_ERR_SHOW_FATAL. <P>
                     86: 
2.9     ! frystyk    87: <B>Note:</B> The default value is made so that it only puts a message to
        !            88: <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
        !            89: be more appropriate.
2.3       frystyk    90: 
                     91: <PRE>
                     92: typedef enum _HTErrorShow {
                     93:     HT_ERR_SHOW_FATAL     = 0x1,
                     94:     HT_ERR_SHOW_NON_FATAL = 0x3,
                     95:     HT_ERR_SHOW_WARNING   = 0x7,
2.6       frystyk    96:     HT_ERR_SHOW_INFO     = 0xF,
                     97:     HT_ERR_SHOW_PARS     = 0x10,
                     98:     HT_ERR_SHOW_LOCATION  = 0x20,
                     99:     HT_ERR_SHOW_IGNORE    = 0x40,
                    100:     HT_ERR_SHOW_FIRST     = 0x80,
2.7       frystyk   101:     HT_ERR_SHOW_DEFAULT          = 0x13,
                    102:     HT_ERR_SHOW_DETAILED  = 0x1F,
                    103:     HT_ERR_SHOW_DEBUG    = 0x7F,
2.3       frystyk   104: } HTErrorShow;
                    105: 
                    106: extern unsigned int HTErrorShowMask;
                    107: </PRE>
2.1       frystyk   108: 
2.3       frystyk   109: This is the table containing the actual error-messages and links for more information:
2.1       frystyk   110: 
                    111: <PRE>
2.3       frystyk   112: typedef struct _HTErrorMsgInfo {
                    113:     int        code;                   /* Error number */
                    114:     char *     msg;                    /* Short explanation */
                    115:     char *     url;                    /* Explaning URL */
                    116: } HTErrorMsgInfo;
                    117: 
                    118: extern HTErrorMsgInfo error_info[];
2.1       frystyk   119: </PRE>
                    120: 
2.3       frystyk   121: <H2>Public Error Functions</H2>
                    122: 
2.1       frystyk   123: <H3>Add an Error Message</H3>
                    124: 
                    125: This function adds an error message to the error_stack list in the HTRequest
2.3       frystyk   126: structure. It always returns a negative value.
2.1       frystyk   127: <PRE>
2.3       frystyk   128: extern int HTErrorAdd PARAMS(( HTRequest *     request,
2.1       frystyk   129:                                HTErrSeverity   severity,
                    130:                                BOOL            ignore,
                    131:                                int             element,
                    132:                                void *          par,
                    133:                                unsigned int    par_length,
                    134:                                char *          where));
2.2       frystyk   135: </PRE>
                    136: 
                    137: <H3>Add a System Error Message</H3>
                    138: 
2.3       frystyk   139: 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   140: <PRE>
2.3       frystyk   141: extern int HTErrorSysAdd PARAMS(( HTRequest *  request,
2.2       frystyk   142:                                  HTErrSeverity severity,
                    143:                                  BOOL          ignore,
                    144:                                  char *        syscall));
2.1       frystyk   145: </PRE>
                    146: 
                    147: <H3>Ignoring an Error Message</H3>
                    148: 
2.7       frystyk   149: If an error message is not to be send to the user, e.g., output to the stream,
                    150: then the ignore flag must be turn on. Theese functions turns it on for the
                    151: latest error appended to the list or an arbitrary error refered to by its 
                    152: handle.
2.1       frystyk   153: <PRE>
2.7       frystyk   154: extern void HTErrorIgnore PARAMS((HTRequest * request, int handle));
                    155: extern void HTErrorIgnoreLast PARAMS((HTRequest * request));
2.1       frystyk   156: </PRE>
                    157: 
2.7       frystyk   158: <H3>Generating an Error Message (default to standard error)</H3>
2.3       frystyk   159: 
2.8       frystyk   160: This function outputs the content of the error_stack to standard output 
                    161: (used in Line Mode Browser), but smart clients and servers might overwrite
                    162: this function so that the error messages can be handled to the user in a nice 
                    163: way. That is the reason for putting the actual implementation in HTErrorMsg.c,
                    164: that can be overwritten by clients and servers apart from Line Mode Browser.<P>
2.3       frystyk   165: 
2.4       frystyk   166: <NOTE><B>Note: </B></NOTE>
2.1       frystyk   167: 
2.8       frystyk   168: If a stream <EM>has</EM> been put up (and maybe taken down again) inside the 
                    169: Library, then request-&gt;error_block has been set to YES. This indicates that
                    170: it is NOT possible any more to use the stream as output for the message.
2.1       frystyk   171: <PRE>
                    172: extern void HTErrorMsg    PARAMS((HTRequest * request));
                    173: </PRE>
                    174: 
                    175: <H3>Freeing an Error List</H3>
                    176: 
2.8       frystyk   177: This is normally done when the HTRequest structure is freed but it might be 
                    178: done at any other time in order to ignore a whole series of errors.
2.1       frystyk   179: <PRE>
                    180: extern void HTErrorFree   PARAMS((HTRequest * request));
                    181: </PRE>
                    182: 
                    183: <PRE>
                    184: #endif
                    185: </PRE>
                    186: end
                    187: </BODY>
                    188: </HTML>
                    189: 
                    190: 

Webmaster