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

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

Webmaster