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

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

E-mail: