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

1.13      parser      1: /** @file
                      2:        Parser: exception class.
                      3: 
1.43      paf         4:        Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
1.38      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.41      paf         6: */
1.13      parser      7: 
1.43.2.2! paf         8: static const char* IDENT_EXCEPTION_C="$Date: 2003/01/23 15:38:06 $";
1.13      parser      9: 
1.43.2.1  paf        10: //#include "pa_common.h"
1.13      parser     11: #include "pa_exception.h"
1.43.2.1  paf        12: //#include "pa_globals.h"
1.39      paf        13: #include "pa_sapi.h"
1.43.2.1  paf        14: #include "pa_string.h"
1.13      parser     15: 
1.43.2.2! paf        16: Exception::problem_source_type Exception::undefined_source=object_ptr<const String>(0);
        !            17: 
1.23      paf        18: Exception::Exception() {
1.40      paf        19:        ftype=0;
                     20:        fproblem_source=0;
1.26      paf        21:        owns_comment=false; fcomment=0;
1.23      paf        22: }
1.40      paf        23: Exception::Exception(const char *atype, 
1.43.2.2! paf        24:                                          problem_source_type aproblem_source, 
1.34      paf        25:                                          const char *comment_fmt, ...) {
1.15      parser     26:        //_asm int 3;
1.27      paf        27: //__asm__("int3");
1.30      paf        28:        ftype=atype;
                     29:        fproblem_source=aproblem_source;
                     30:        owns_comment=true;
1.27      paf        31: 
1.13      parser     32:        if(comment_fmt) {
1.26      paf        33:                fcomment=(char *)malloc(MAX_STRING);
1.39      paf        34:                if(!fcomment)
                     35:                        SAPI::die("out of memory in 'Exception::Exception', failed to allocated %u bytes", MAX_STRING);
1.34      paf        36:                va_list args;
                     37:                va_start(args, comment_fmt);
1.13      parser     38:                vsnprintf(fcomment, MAX_STRING, comment_fmt, args);
1.34      paf        39:                va_end(args);
1.26      paf        40:        } else
                     41:                fcomment=0;
                     42: }
1.33      paf        43: 
                     44: #ifdef XML
1.28      paf        45: Exception::Exception(
                     46:        const String *aproblem_source, 
                     47:        GdomeException& exc) :
1.40      paf        48:        ftype("xml"),
1.28      paf        49:        fproblem_source(aproblem_source),
                     50:        owns_comment(true) {
                     51: 
1.31      paf        52:        const char *xml_generic_errors=xmlGenericErrors();
                     53:        if(xml_generic_errors || exc) {
1.28      paf        54:                const char *s;
                     55:                switch((GdomeExceptionCode)exc) {
                     56:                case GDOME_NOEXCEPTION_ERR: s="NOEXCEPTION_ERR"; break;
                     57:                case GDOME_INDEX_SIZE_ERR: s="INDEX_SIZE_ERR"; break;
                     58:                case GDOME_DOMSTRING_SIZE_ERR: s="DOMSTRING_SIZE_ERR"; break;
                     59:                case GDOME_HIERARCHY_REQUEST_ERR: s="HIERARCHY_REQUEST_ERR"; break;
                     60:                case GDOME_WRONG_DOCUMENT_ERR: s="WRONG_DOCUMENT_ERR"; break;
                     61:                case GDOME_INVALID_CHARACTER_ERR: s="INVALID_CHARACTER_ERR"; break;
                     62:                case GDOME_NO_DATA_ALLOWED_ERR: s="NO_DATA_ALLOWED_ERR"; break;
                     63:                case GDOME_NO_MODIFICATION_ALLOWED_ERR: s="NO_MODIFICATION_ALLOWED_ERR"; break;
                     64:                case GDOME_NOT_FOUND_ERR: s="NOT_FOUND_ERR"; break;
                     65:                case GDOME_NOT_SUPPORTED_ERR: s="NOT_SUPPORTED_ERR"; break;
                     66:                case GDOME_INUSE_ATTRIBUTE_ERR: s="INUSE_ATTRIBUTE_ERR"; break;
                     67:                case GDOME_INVALID_STATE_ERR: s="INVALID_STATE_ERR"; break;
                     68:                case GDOME_SYNTAX_ERR: s="SYNTAX_ERR"; break;
                     69:                case GDOME_INVALID_MODIFICATION_ERR: s="INVALID_MODIFICATION_ERR"; break;
                     70:                case GDOME_NAMESPACE_ERR: s="NAMESPACE_ERR"; break;
                     71:                case GDOME_INVALID_ACCESS_ERR: s="INVALID_ACCESS_ERR"; break;
                     72:                case GDOME_NULL_POINTER_ERR: s="NULL_POINTER_ERR"; break;
                     73:                default: s="<UNKNOWN CODE>"; break;
                     74:                }
                     75:                
                     76:                fcomment=(char *)malloc(MAX_STRING);
1.36      paf        77:                const char *xml_error_message;
                     78:                const char *xml_error_prefix;
                     79:                if(xml_generic_errors) {
                     80:                        xml_error_prefix="\n";
                     81:                        xml_error_message=xml_generic_errors;
                     82:                } else {
                     83:                        xml_error_prefix="";
                     84:                        xml_error_message="";
                     85:                }
1.32      paf        86:                if(exc)
                     87:                        snprintf(fcomment, MAX_STRING, 
1.35      paf        88:                                "DOMException %s (%d)."
                     89:                                "%s%s", 
1.32      paf        90:                                        s,  // decoded code of exception
                     91:                                        exc, // DOM exception code
1.35      paf        92:                                        xml_error_prefix, xml_error_message // xml generic messages accumulated
1.32      paf        93:                        );
                     94:                else // no DOM exception
                     95:                        snprintf(fcomment, MAX_STRING, 
                     96:                                "%s", 
                     97:                                        xml_error_message // xml generic messages accumulated
                     98:                        );
1.31      paf        99:                if(xml_generic_errors)
                    100:                        free((void *)xml_generic_errors);
1.28      paf       101:        } else
1.29      paf       102:                fcomment=0;
1.28      paf       103: }
1.18      parser    104: #endif
1.43.2.1  paf       105: 
                    106: object_ptr<const String> Exception::problem_source() const { 
                    107:        return fproblem_source && fproblem_source->size()?fproblem_source:0; 
                    108: }

E-mail: