Annotation of parser3/src/main/pa_exception.C, revision 1.25

1.13      parser      1: /** @file
                      2:        Parser: exception class.
                      3: 
                      4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.24      paf         5:        Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)
1.13      parser      6: 
1.25    ! paf         7:        $Id: pa_exception.C,v 1.24 2001/11/05 11:46:28 paf Exp $
1.13      parser      8: */
                      9: 
                     10: #include "pa_common.h"
                     11: #include "pa_exception.h"
                     12: 
1.23      paf        13: Exception::Exception() {
                     14:        ftype=fcode=fproblem_source=0;
1.25    ! paf        15:        fcomment[0]=0;
1.23      paf        16: }
1.19      parser     17: Exception::Exception(const String *atype, const String *acode,
1.13      parser     18:                                          const String *aproblem_source, 
1.19      parser     19:                                          const char *comment_fmt, ...) {
1.15      parser     20:        //_asm int 3;
1.13      parser     21:        ftype=atype;
                     22:        fcode=acode;
                     23:        fproblem_source=aproblem_source;
                     24: 
                     25:        if(comment_fmt) {
                     26:                va_list args;
                     27:                va_start(args, comment_fmt);
                     28:                vsnprintf(fcomment, MAX_STRING, comment_fmt, args);
                     29:                va_end(args);
                     30:        } else 
1.25    ! paf        31:                fcomment[0]=0;
1.13      parser     32: }
1.17      parser     33: 
1.18      parser     34: #ifdef XML
1.22      parser     35: void Exception::provide_source(Pool& pool, const String *source, const XSLException& e) {
1.17      parser     36:        if(e.getURI().empty())
1.20      parser     37:                throw Exception(0, 0,
1.17      parser     38:                        source,
                     39:                        "%s (%s)",
                     40:                                pool.transcode_cstr(e.getMessage()),  // message for exception
                     41:                                pool.transcode_cstr(e.getType()) // type of exception
                     42:                );
                     43:        else
1.20      parser     44:                throw Exception(0, 0,
1.17      parser     45:                        source,
                     46:                        "%s (%s). %s(%d:%d)'", 
                     47:                                pool.transcode_cstr(e.getMessage()),  // message for exception
                     48:                                pool.transcode_cstr(e.getType()), // type of exception
                     49:                                
                     50:                                pool.transcode_cstr(e.getURI()),  // URI for the associated document, if any
                     51:                                e.getLineNumber(),  // line number, or -1 if unknown
                     52:                                e.getColumnNumber() // column number, or -1 if unknown
                     53:                );
                     54: }
                     55: 
1.22      parser     56: void Exception::provide_source(Pool& pool, const String *source, const SAXException& e) {
1.20      parser     57:        throw Exception(0, 0,
1.17      parser     58:                source,
                     59:                "%s",
                     60:                        pool.transcode_cstr(XalanDOMString(e.getMessage()))  // message for exception
                     61:        );
                     62: }
1.22      parser     63: void Exception::provide_source(Pool& pool, const String *source, const SAXParseException& e) {
1.20      parser     64:        throw Exception(0, 0,
1.17      parser     65:                source,
                     66:                "%s. %s(%d:%d)",
                     67:                        pool.transcode_cstr(XalanDOMString(e.getMessage())),  // message for exception
                     68:                        e.getSystemId()?pool.transcode_cstr(XalanDOMString(e.getSystemId())):"block", // file of exception
                     69:                        e.getLineNumber(), e.getColumnNumber() // line:col
                     70:        );
                     71: }
                     72: 
                     73: 
1.22      parser     74: void Exception::provide_source(Pool& pool, const String *source, const XMLException& e) {
1.20      parser     75:        throw Exception(0, 0,
1.17      parser     76:                source,
                     77:                "%s (%s). %s(%d)'", 
                     78:                        pool.transcode_cstr(XalanDOMString(e.getMessage())),  // message for exception
1.20      parser     79:                        pool.transcode_cstr(XalanDOMString(e.getType())), // type of exception
1.17      parser     80:                        
                     81:                        e.getSrcFile()?e.getSrcFile():"block", // file of exception
                     82:                        e.getSrcLine()  // line number
                     83:                        //e.getCode()
                     84:        );
                     85: }
                     86: 
1.22      parser     87: void Exception::provide_source(Pool& pool, const String *source, const XalanDOMException& e) {
1.17      parser     88:        const char *s;
                     89:        int code=(int)e.getExceptionCode();
                     90:        switch(code) {
                     91:        case 1: s="INDEX_SIZE_ERR"; break;
                     92:        case 2: s="DOMSTRING_SIZE_ERR"; break;
                     93:        case 3: s="HIERARCHY_REQUEST_ERR"; break;
                     94:        case 4: s="WRONG_DOCUMENT_ERR"; break;
                     95:        case 5: s="INVALID_CHARACTER_ERR"; break;
                     96:        case 6: s="NO_DATA_ALLOWED_ERR"; break;
                     97:        case 7: s="NO_MODIFICATION_ALLOWED_ERR"; break;
                     98:        case 8: s="NOT_FOUND_ERR"; break;
                     99:        case 9: s="NOT_SUPPORTED_ERR"; break;
                    100:        case 10: s="INUSE_ATTRIBUTE_ERR"; break;
                    101:        case 11: s="INVALID_STATE_ERR"; break;
                    102:        case 12: s="SYNTAX_ERR"; break;
                    103:        case 13: s="INVALID_MODIFICATION_ERR"; break;
                    104:        case 14: s="NAMESPACE_ERR"; break;
                    105:        case 15: s="INVALID_ACCESS_ERR"; break;
                    106:        case 201: s="UNKNOWN_ERR"; break;
                    107:        case 202: s="TRANSCODING_ERR"; break;
                    108:        default: s="<UNKNOWN CODE>"; break;
                    109:        }
1.20      parser    110:        throw Exception(0, 0,
1.17      parser    111:                source,
                    112:                "XalanDOMException %s (%d)",
                    113:                        s,  // decoded code of exception
                    114:                        code // code of exception
                    115:        );
                    116: }
1.18      parser    117: #endif

E-mail: