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

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

E-mail: