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

1.13      parser      1: /** @file
                      2:        Parser: exception class.
                      3: 
1.43.2.10  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.14! paf         8: static const char* IDENT_EXCEPTION_C="$Date: 2003/02/19 16:19:00 $";
1.13      parser      9: 
1.43.2.3  paf        10: #include "pa_common.h"
1.13      parser     11: #include "pa_exception.h"
1.39      paf        12: #include "pa_sapi.h"
1.43.2.14! paf        13: #include "pa_globals.h"
1.43.2.8  paf        14: 
                     15: // statics
                     16: 
                     17: 
                     18: const char* Exception::undefined_type=0;
1.43.2.9  paf        19: const StringPtr Exception::undefined_source(0);
1.43.2.8  paf        20: 
                     21: // methods
1.43.2.2  paf        22: 
1.23      paf        23: Exception::Exception() {
1.40      paf        24:        ftype=0;
1.43.2.3  paf        25:        fproblem_source=undefined_source;
1.43.2.4  paf        26:        fcomment=CharPtr(0);
1.23      paf        27: }
1.43.2.11  paf        28: Exception::Exception(const Exception& src):
                     29:        ftype(src.ftype),
                     30:        fproblem_source(src.fproblem_source),
                     31:        fcomment(src.fcomment) {
                     32: }
                     33: Exception& Exception::operator =(const Exception& src) {
                     34:        ftype=src.ftype;
                     35:        fproblem_source=src.fproblem_source;
                     36:        fcomment=src.fcomment;
                     37:        return *this;
                     38: }
                     39: 
                     40: 
                     41: 
1.43.2.10  paf        42: Exception::Exception(const char* atype, 
1.43.2.9  paf        43:                                          StringPtr aproblem_source, 
1.43.2.10  paf        44:                                          const char* comment_fmt, ...) {
1.15      parser     45:        //_asm int 3;
1.27      paf        46: //__asm__("int3");
1.30      paf        47:        ftype=atype;
                     48:        fproblem_source=aproblem_source;
1.27      paf        49: 
1.13      parser     50:        if(comment_fmt) {
1.43.2.14! paf        51:                fcomment=CharPtr(new char[MAX_STRING]);
1.34      paf        52:                va_list args;
                     53:                va_start(args, comment_fmt);
1.43.2.14! paf        54:                vsnprintf(fcomment, MAX_STRING, comment_fmt, args);
1.34      paf        55:                va_end(args);
1.26      paf        56:        } else
1.43.2.14! paf        57:                fcomment=CharPtr(0);
1.26      paf        58: }
1.33      paf        59: 
                     60: #ifdef XML
1.28      paf        61: Exception::Exception(
1.43.2.14! paf        62:        StringPtr aproblem_source, 
1.28      paf        63:        GdomeException& exc) :
1.40      paf        64:        ftype("xml"),
1.43.2.14! paf        65:        fproblem_source(aproblem_source) {
1.28      paf        66: 
1.43.2.14! paf        67:        CharPtr xml_generic_errors=xmlGenericErrors();
        !            68:        if(xml_generic_errors.get() || exc) {
1.43.2.10  paf        69:                const char* s;
1.28      paf        70:                switch((GdomeExceptionCode)exc) {
                     71:                case GDOME_NOEXCEPTION_ERR: s="NOEXCEPTION_ERR"; break;
                     72:                case GDOME_INDEX_SIZE_ERR: s="INDEX_SIZE_ERR"; break;
                     73:                case GDOME_DOMSTRING_SIZE_ERR: s="DOMSTRING_SIZE_ERR"; break;
                     74:                case GDOME_HIERARCHY_REQUEST_ERR: s="HIERARCHY_REQUEST_ERR"; break;
                     75:                case GDOME_WRONG_DOCUMENT_ERR: s="WRONG_DOCUMENT_ERR"; break;
                     76:                case GDOME_INVALID_CHARACTER_ERR: s="INVALID_CHARACTER_ERR"; break;
                     77:                case GDOME_NO_DATA_ALLOWED_ERR: s="NO_DATA_ALLOWED_ERR"; break;
                     78:                case GDOME_NO_MODIFICATION_ALLOWED_ERR: s="NO_MODIFICATION_ALLOWED_ERR"; break;
                     79:                case GDOME_NOT_FOUND_ERR: s="NOT_FOUND_ERR"; break;
                     80:                case GDOME_NOT_SUPPORTED_ERR: s="NOT_SUPPORTED_ERR"; break;
                     81:                case GDOME_INUSE_ATTRIBUTE_ERR: s="INUSE_ATTRIBUTE_ERR"; break;
                     82:                case GDOME_INVALID_STATE_ERR: s="INVALID_STATE_ERR"; break;
                     83:                case GDOME_SYNTAX_ERR: s="SYNTAX_ERR"; break;
                     84:                case GDOME_INVALID_MODIFICATION_ERR: s="INVALID_MODIFICATION_ERR"; break;
                     85:                case GDOME_NAMESPACE_ERR: s="NAMESPACE_ERR"; break;
                     86:                case GDOME_INVALID_ACCESS_ERR: s="INVALID_ACCESS_ERR"; break;
                     87:                case GDOME_NULL_POINTER_ERR: s="NULL_POINTER_ERR"; break;
                     88:                default: s="<UNKNOWN CODE>"; break;
                     89:                }
                     90:                
1.43.2.14! paf        91:                fcomment=CharPtr(new char[MAX_STRING]);
1.43.2.10  paf        92:                const char* xml_error_message;
                     93:                const char* xml_error_prefix;
1.36      paf        94:                if(xml_generic_errors) {
                     95:                        xml_error_prefix="\n";
                     96:                        xml_error_message=xml_generic_errors;
                     97:                } else {
                     98:                        xml_error_prefix="";
                     99:                        xml_error_message="";
                    100:                }
1.32      paf       101:                if(exc)
                    102:                        snprintf(fcomment, MAX_STRING, 
1.35      paf       103:                                "DOMException %s (%d)."
                    104:                                "%s%s", 
1.32      paf       105:                                        s,  // decoded code of exception
                    106:                                        exc, // DOM exception code
1.35      paf       107:                                        xml_error_prefix, xml_error_message // xml generic messages accumulated
1.32      paf       108:                        );
                    109:                else // no DOM exception
                    110:                        snprintf(fcomment, MAX_STRING, 
                    111:                                "%s", 
                    112:                                        xml_error_message // xml generic messages accumulated
                    113:                        );
1.31      paf       114:                if(xml_generic_errors)
                    115:                        free((void *)xml_generic_errors);
1.28      paf       116:        } else
1.43.2.14! paf       117:                fcomment=CharPtr(0);
1.28      paf       118: }
1.18      parser    119: #endif
1.43.2.1  paf       120: 
1.43.2.9  paf       121: StringPtr Exception::problem_source() const { 
1.43.2.4  paf       122:        return fproblem_source.get() && fproblem_source->size()?fproblem_source:undefined_source; 
1.43.2.1  paf       123: }

E-mail: