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

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.40      frystyk     3:   <!-- Changed by: Henrik Frystyk Nielsen,  4-Jul-1996 -->
2.37      frystyk     4:   <TITLE>W3C Reference Library libwww Error Class</TITLE>
2.1       frystyk     5: </HEAD>
                      6: <BODY>
2.37      frystyk     7: <H1>
                      8:   The Error Class
                      9: </H1>
2.18      frystyk    10: <PRE>
                     11: /*
2.22      frystyk    12: **     (c) COPYRIGHT MIT 1995.
2.18      frystyk    13: **     Please first read the full copyright statement in the file COPYRIGH.
                     14: */
                     15: </PRE>
2.37      frystyk    16: <P>
                     17: The Error class provides an easy API for registering errors ocurring while
                     18: the Library serves a request. All errors are registered in an "error
                     19: stack"&nbsp;in the <A HREF="HTReq.html">Request object</A> which allows for
                     20: nested errors. The Error class is both natural language independent and
                     21: application independent in that it uses enumerations in order to refer to
                     22: specific errors. It is for the application to provide an error presentation
                     23: module which interprets the errors associated with a request. An eample of
                     24: such an implementation can be found in the <A HREF="HTDialog.html">HTDialog
                     25: module</A>.
                     26: <P>
                     27: This module is implemented by <A HREF="HTError.c">HTError.c</A>, and it is
                     28: a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Reference
                     29: Library</A>.
2.1       frystyk    30: <PRE>
                     31: #ifndef HTERROR_H
                     32: #define HTERROR_H
2.36      frystyk    33: 
                     34: typedef struct _HTError HTError;
                     35: 
                     36: typedef enum _HTSeverity {
                     37:     ERR_UNKNOWN                  = 0x0,
                     38:     ERR_FATAL            = 0x1,
                     39:     ERR_NON_FATAL        = 0x2,
                     40:     ERR_WARN             = 0x4,
                     41:     ERR_INFO             = 0x8
                     42: } HTSeverity;
                     43: 
2.28      frystyk    44: #include "HTReq.h"
2.1       frystyk    45: </PRE>
2.37      frystyk    46: <H2>
                     47:   <A NAME="errorinfo">Error Codes and Messages</A>
                     48: </H2>
                     49: <P>
                     50: <B>Note:</B> All non-HTTP error codes have index numbers &gt; HTERR_HTTP_CODES,
                     51: and they will not be shown in the error-message generated.
2.1       frystyk    52: <PRE>
                     53: typedef enum _HTErrorElement {
2.38      frystyk    54:        HTERR_CONTINUE = 0,                                     /* 100 */
                     55:        HTERR_SWITCHING,                                        /* 101 */
                     56:        HTERR_OK,                                               /* 200 */
2.1       frystyk    57:        HTERR_CREATED,                                          /* 201 */
                     58:        HTERR_ACCEPTED,                                         /* 202 */
2.38      frystyk    59:        HTERR_NON_AUTHORITATIVE,                                /* 203 */
2.23      frystyk    60:        HTERR_NO_CONTENT,                                       /* 204 */
2.38      frystyk    61:        HTERR_RESET,                                            /* 205 */
                     62:        HTERR_PARTIAL,                                          /* 206 */
                     63:        HTERR_MULTIPLE,                                         /* 300 */
2.1       frystyk    64:        HTERR_MOVED,                                            /* 301 */
                     65:        HTERR_FOUND,                                            /* 302 */
                     66:        HTERR_METHOD,                                           /* 303 */
                     67:        HTERR_NOT_MODIFIED,                                     /* 304 */
2.38      frystyk    68:        HTERR_USE_PROXY,                                        /* 305 */
2.1       frystyk    69:        HTERR_BAD_REQUEST,                                      /* 400 */
                     70:        HTERR_UNAUTHORIZED,                                     /* 401 */
                     71:        HTERR_PAYMENT_REQUIRED,                                 /* 402 */
                     72:        HTERR_FORBIDDEN,                                        /* 403 */
                     73:        HTERR_NOT_FOUND,                                        /* 404 */
2.20      frystyk    74:        HTERR_NOT_ALLOWED,                                      /* 405 */
                     75:        HTERR_NONE_ACCEPTABLE,                                  /* 406 */
2.38      frystyk    76:        HTERR_PROXY_UNAUTHORIZED,                               /* 407 */
2.20      frystyk    77:        HTERR_TIMEOUT,                                          /* 408 */
2.38      frystyk    78:        HTERR_CONFLICT,                                         /* 409 */
                     79:        HTERR_GONE,                                             /* 410 */
                     80:        HTERR_LENGTH_REQUIRED,                                  /* 411 */
                     81:        HTERR_PRECON_FAILED,                                    /* 412 */
                     82:        HTERR_TOO_BIG,                                          /* 413 */
                     83:        HTERR_URI_TOO_BIG,                                      /* 414 */
                     84:        HTERR_UNSUPPORTED,                                      /* 415 */
2.1       frystyk    85:        HTERR_INTERNAL,                                         /* 500 */
                     86:        HTERR_NOT_IMPLEMENTED,                                  /* 501 */
2.20      frystyk    87:        HTERR_BAD_GATE,                                         /* 502 */
                     88:        HTERR_DOWN,                                             /* 503 */
                     89:        HTERR_GATE_TIMEOUT,                                     /* 504 */
2.38      frystyk    90:        HTERR_BAD_VERSION,                                      /* 505 */
                     91: 
                     92:        /* Cache warnings */
                     93:        HTERR_STALE,                                            /* 10 */
                     94:        HTERR_REVALIDATION_FAILED,                              /* 11 */
                     95:        HTERR_DISCONNECTED_CACHE,                               /* 12 */
                     96:        HTERR_HEURISTIC_EXPIRATION,                             /* 13 */
                     97:        HTERR_TRANSFORMED,                                      /* 14 */
                     98:        HTERR_CACHE,                                            /* 99 */
                     99: 
                    100:        /* Put all non-HTTP status codes after this */
2.1       frystyk   101:        HTERR_NO_REMOTE_HOST,
2.13      frystyk   102:        HTERR_NO_HOST,
2.31      frystyk   103:        HTERR_NO_FILE,
2.1       frystyk   104:        HTERR_FTP_SERVER,
                    105:        HTERR_FTP_NO_RESPONSE,
                    106:        HTERR_TIME_OUT,
2.2       frystyk   107:        HTERR_GOPHER_SERVER,
                    108:        HTERR_INTERRUPTED,
2.13      frystyk   109:        HTERR_CON_INTR,
2.2       frystyk   110:        HTERR_CSO_SERVER,
2.20      frystyk   111:        HTERR_HTTP09,
                    112:        HTERR_BAD_REPLY,
2.16      frystyk   113:        HTERR_UNKNOWN_AA,
2.5       frystyk   114:        HTERR_NEWS_SERVER,
2.7       frystyk   115:        HTERR_FILE_TO_FTP,
2.39      frystyk   116:        HTERR_AUTO_REDIRECT,
2.8       frystyk   117:        HTERR_MAX_REDIRECT,
2.16      frystyk   118:        HTERR_EOF,
2.14      frystyk   119:        HTERR_WAIS_OVERFLOW,
                    120:        HTERR_WAIS_MODULE,
2.12      frystyk   121:        HTERR_WAIS_NO_CONNECT,
2.2       frystyk   122:        HTERR_SYSTEM,
2.29      frystyk   123:        HTERR_CLASS,
2.31      frystyk   124:        HTERR_ACCESS,
                    125:        HTERR_LOGIN,
2.41    ! frystyk   126:         HTERR_CACHE_EXPIRED,
2.1       frystyk   127:        HTERR_ELEMENTS                      /* This MUST be the last element */
                    128: } HTErrorElement;
2.30      frystyk   129: </PRE>
2.37      frystyk   130: <H2>
                    131:   What Errors should be Parsed Through?
                    132: </H2>
                    133: <P>
                    134: This variable dictates which errors should be put out when generating the
                    135: message to the user. The first four enumerations make it possible to see
                    136: `everything as bad or worse than' this level, e.g. <CODE>HT_ERR_SHOW_NON_FATAL
                    137: </CODE>shows messages of type <CODE>HT_ERR_SHOW_NON_FATAL </CODE>and
                    138: <CODE>HT_ERR_SHOW_FATAL</CODE>.
                    139: <P>
                    140: <B>Note:</B> The default value is made so that it only puts a message to
                    141: <EM>stderr</EM> if a `real' error has occurred. If a separate widget is available
                    142: for information and error messages then probably
                    143: <CODE>HT_ERR_SHOW_DETAILED</CODE> would be more appropriate.
                    144: <PRE>
                    145: typedef enum _HTErrorShow {
                    146:     HT_ERR_SHOW_FATAL     = 0x1,
                    147:     HT_ERR_SHOW_NON_FATAL = 0x3,
                    148:     HT_ERR_SHOW_WARNING   = 0x7,
                    149:     HT_ERR_SHOW_INFO     = 0xF,
                    150:     HT_ERR_SHOW_PARS     = 0x10,
                    151:     HT_ERR_SHOW_LOCATION  = 0x20,
                    152:     HT_ERR_SHOW_IGNORE    = 0x40,
                    153:     HT_ERR_SHOW_FIRST     = 0x80,
                    154:     HT_ERR_SHOW_LINKS     = 0x100,
                    155:     HT_ERR_SHOW_DEFAULT          = 0x13,
                    156:     HT_ERR_SHOW_DETAILED  = 0x1F,
                    157:     HT_ERR_SHOW_DEBUG    = 0x7F
                    158: } HTErrorShow;
2.19      roeber    159: 
2.37      frystyk   160: extern HTErrorShow HTError_show (void);
                    161: extern BOOL HTError_setShow (HTErrorShow mask);
                    162: </PRE>
                    163: <H2>
                    164:   Creation and Deletion Methods
                    165: </H2>
                    166: <H3>
                    167:   Add an Error
                    168: </H3>
                    169: <P>
                    170: Add an error message to the error list. `par' and `where' might be set to
                    171: NULL. If par is a string, it is sufficient to let length be unspecified,
                    172: i.e., 0. If only a part of the string is wanted then specify a length inferior
                    173: to strlen((char *) par). The string is '\0' terminated automaticly. See also
                    174: HTError_addSystem for system errors. Returns YES if OK, else NO.
2.30      frystyk   175: <PRE>
                    176: extern BOOL HTError_add (HTList *      list,
                    177:                         HTSeverity     severity,
                    178:                         BOOL           ignore,
                    179:                         int            element,
                    180:                         void *         par,
                    181:                         unsigned int   length,
                    182:                         char *         where);
                    183: 
                    184: </PRE>
2.37      frystyk   185: <H3>
                    186:   Add a System Error
                    187: </H3>
                    188: <P>
                    189: Add a system error message to the error list. syscall is the name of the
                    190: system call, e.g. "close". The message put to the list is that corresponds
                    191: to the error number passed. See also HTError_add. Returns YES if OK, else
                    192: NO.
2.30      frystyk   193: <PRE>
                    194: extern BOOL HTError_addSystem (HTList *                list,
                    195:                               HTSeverity       severity,
                    196:                               int              errornumber,
                    197:                               BOOL             ignore,
                    198:                               char *           syscall);
                    199: </PRE>
2.37      frystyk   200: <H3>
                    201:   Delete an Entire Error Stack
                    202: </H3>
                    203: <P>
2.30      frystyk   204: Deletes all errors in a list.
                    205: <PRE>
                    206: extern BOOL HTError_deleteAll (HTList * list);
2.1       frystyk   207: </PRE>
2.37      frystyk   208: <H3>
                    209:   Deletes the Last Edded Entry
                    210: </H3>
                    211: <P>
2.30      frystyk   212: Deletes the last error entry added to the list. Return YES if OK, else NO
                    213: <PRE>
                    214: extern BOOL HTError_deleteLast (HTList * list);
                    215: </PRE>
2.37      frystyk   216: <H2>
2.40      frystyk   217:   Object Methods
2.37      frystyk   218: </H2>
                    219: <H3>
                    220:   Show the Error Entry?
                    221: </H3>
                    222: <P>
2.30      frystyk   223: Should we show this entry in the list or just continue to the next one?
2.1       frystyk   224: <PRE>
2.30      frystyk   225: extern BOOL HTError_doShow (HTError * info);
2.1       frystyk   226: </PRE>
2.37      frystyk   227: <H3>
                    228:   Ignore last Added Error
                    229: </H3>
                    230: <P>
                    231: Turns on the `ignore' flag for the most recent error entered the error list.
                    232: Returns YES if OK else NO
2.1       frystyk   233: <PRE>
2.30      frystyk   234: extern BOOL HTError_ignoreLast (HTList * list);
                    235: extern BOOL HTError_setIgnore  (HTError * info);
2.2       frystyk   236: </PRE>
2.37      frystyk   237: <H3>
                    238:   Error Index Number
                    239: </H3>
                    240: <P>
                    241: Each error object is assigned an index number as defined by the
                    242: <CODE>HTErrorElement</CODE> above. The mapping from this index to an error
                    243: code and a message must be done by the application. The Library provides
                    244: a default implementation in the <A HREF="HTDialog.html"> HTDialog module</A>,
                    245: but that can of course be changed depending on the application.
2.15      frystyk   246: <PRE>
2.31      frystyk   247: extern int HTError_index               (HTError * info);
2.37      frystyk   248: </PRE>
                    249: <H3>
                    250:   Error Severity
                    251: </H3>
2.40      frystyk   252: <P>
                    253: This function returns the severity of the error object passed by the caller
                    254: <PRE>extern HTSeverity HTError_severity        (HTError * info);
                    255: </PRE>
                    256: <P>
                    257: You can ask whether a list of errors contains any error object with a severity
                    258: level which is higher than the one specifed.
                    259: <PRE>extern BOOL HTError_hasSeverity   (HTList * list, HTSeverity severity);
2.37      frystyk   260: </PRE>
                    261: <H3>
                    262:   Parameters Asscotiated with Error
                    263: </H3>
                    264: <PRE>
2.30      frystyk   265: extern void * HTError_parameter                (HTError * info, int * length);
2.37      frystyk   266: </PRE>
                    267: <H3>
                    268:   Where did it happen?
                    269: </H3>
                    270: <PRE>
2.34      frystyk   271: extern const char * HTError_location   (HTError * info);
2.1       frystyk   272: </PRE>
                    273: <PRE>
                    274: #endif
                    275: </PRE>
2.37      frystyk   276: <P>
                    277:   <HR>
2.36      frystyk   278: <ADDRESS>
2.41    ! frystyk   279:   @(#) $Id: HTError.html,v 2.40 1996/08/05 17:22:16 frystyk Exp $
2.36      frystyk   280: </ADDRESS>
2.37      frystyk   281: </BODY></HTML>

Webmaster