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

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

Webmaster