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

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

Webmaster