Diff for /parser3/src/main/pa_exception.C between versions 1.29 and 1.43.2.15.2.4

version 1.29, 2001/12/28 18:12:30 version 1.43.2.15.2.4, 2003/03/20 14:19:09
Line 1 Line 1
 /** @file  /** @file
         Parser: exception class.          Parser: exception class.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
   
         $Id$  
 */  */
   
   static const char* IDENT_EXCEPTION_C="$Date$";
   
 #include "pa_common.h"  #include "pa_common.h"
 #include "pa_exception.h"  #include "pa_exception.h"
   #include "pa_sapi.h"
   #include "pa_globals.h"
   
   
 Exception::Exception() {  // methods
         ftype=fcode=fproblem_source=0;  
         owns_comment=false; fcomment=0;  Exception::Exception(): ftype(0), fproblem_source(0), fcomment(0) {}
   Exception::Exception(const Exception& src):
           ftype(src.ftype),
           fproblem_source(src.fproblem_source),
           fcomment(src.fcomment) {
   }
   Exception& Exception::operator =(const Exception& src) {
           ftype=src.ftype;
           fproblem_source=src.fproblem_source;
           fcomment=src.fcomment;
           return *this;
 }  }
 Exception::Exception(const String *atype, const String *acode,  
                                           const String *aproblem_source,   
                                           const char *comment_fmt, ...) :   
         ftype(atype),  Exception::Exception(const char* atype, 
         fcode(acode),                                            const String* aproblem_source, 
         fproblem_source(aproblem_source),                                            const char* comment_fmt, ...) {
         owns_comment(true) {  
         //_asm int 3;          //_asm int 3;
 //__asm__("int3");  //__asm__("int3");
           ftype=atype;
           fproblem_source=aproblem_source;
   
         if(comment_fmt) {          if(comment_fmt) {
                   fcomment=new(PointerFreeGC) char[MAX_STRING];
                 va_list args;                  va_list args;
                 va_start(args, comment_fmt);                  va_start(args, comment_fmt);
                 fcomment=(char *)malloc(MAX_STRING);  
                 vsnprintf(fcomment, MAX_STRING, comment_fmt, args);                  vsnprintf(fcomment, MAX_STRING, comment_fmt, args);
                 va_end(args);                  va_end(args);
         } else          } else
                 fcomment=0;                  fcomment=0;
 }  }
   
   #ifdef XML
 Exception::Exception(  Exception::Exception(
         const String *atype, const String *acode,          const String* aproblem_source, 
         const String *aproblem_source,   
         GdomeException& exc) :          GdomeException& exc) :
         ftype(atype),          ftype("xml"),
         fcode(acode),          fproblem_source(aproblem_source) {
         fproblem_source(aproblem_source),  
         owns_comment(true) {  
   
         if(exc) {          const char* xml_generic_errors=xmlGenericErrors();
                 const char *s;          if(xml_generic_errors.get() || exc) {
                   const char* s;
                 switch((GdomeExceptionCode)exc) {                  switch((GdomeExceptionCode)exc) {
                 case GDOME_NOEXCEPTION_ERR: s="NOEXCEPTION_ERR"; break;                  case GDOME_NOEXCEPTION_ERR: s="NOEXCEPTION_ERR"; break;
                 case GDOME_INDEX_SIZE_ERR: s="INDEX_SIZE_ERR"; break;                  case GDOME_INDEX_SIZE_ERR: s="INDEX_SIZE_ERR"; break;
Line 65  Exception::Exception( Line 79  Exception::Exception(
                 default: s="<UNKNOWN CODE>"; break;                  default: s="<UNKNOWN CODE>"; break;
                 }                  }
                                   
                 fcomment=(char *)malloc(MAX_STRING);                  fcomment=CharPtr(new char[MAX_STRING]);
                 snprintf(fcomment, MAX_STRING,                   const char* xml_error_message;
                         "DOMException %s (%d)",                   const char* xml_error_prefix;
                                 s,  // decoded code of exception                  if(xml_generic_errors) {
                                 exc // code of exception                          xml_error_prefix="\n";
                 );                          xml_error_message=xml_generic_errors;
                   } else {
                           xml_error_prefix="";
                           xml_error_message="";
                   }
                   if(exc)
                           snprintf(fcomment, MAX_STRING, 
                                   "DOMException %s (%d)."
                                   "%s%s", 
                                           s,  // decoded code of exception
                                           exc, // DOM exception code
                                           xml_error_prefix, xml_error_message // xml generic messages accumulated
                           );
                   else // no DOM exception
                           snprintf(fcomment, MAX_STRING, 
                                   "%s", 
                                           xml_error_message // xml generic messages accumulated
                           );
         } else          } else
                 fcomment=0;                  fcomment=CharPtr(0);
 }  }
   #endif
   
   const String* Exception::problem_source() const { 
 Exception::Exception(const Exception& src) :           return fproblem_source && fproblem_source->length()?fproblem_source:0; 
         ftype(src.ftype),  
         fcode(src.fcode),  
         fproblem_source(src.fproblem_source),  
         fcomment(src.fcomment),  
         owns_comment(src.owns_comment) {  
         // that ugly string got from STL, along with principal ideal  
         const_cast<Exception *>(&src)->owns_comment=false;  
 }  
 Exception& Exception::operator =(const Exception& src) {  
         ftype=src.ftype;  
         fcode=src.fcode;  
         fproblem_source=src.fproblem_source;  
   
         if(owns_comment)  
                 free(fcomment);  
         fcomment=src.fcomment;  
         // that ugly string got from STL, along with principal ideal  
         owns_comment=src.owns_comment;  ((Exception*)&src)->owns_comment=false;  
           
         return *this;  
 }  
 Exception::~Exception() {  
         if(owns_comment)  
                 free(fcomment);  
 }  
   
 #ifdef XML  
 /*  
 void Exception::provide_source(Pool& pool, const String *source, const XSLException& e) {  
         if(e.getURI().empty())  
                 throw Exception(0, 0,  
                         source,  
                         "%s (%s)",  
                                 pool.transcode_cstr(e.getMessage()),  // message for exception  
                                 pool.transcode_cstr(e.getType()) // type of exception  
                 );  
         else  
                 throw Exception(0, 0,  
                         source,  
                         "%s (%s). %s(%d:%d)'",   
                                 pool.transcode_cstr(e.getMessage()),  // message for exception  
                                 pool.transcode_cstr(e.getType()), // type of exception  
                                   
                                 pool.transcode_cstr(e.getURI()),  // URI for the associated document, if any  
                                 e.getLineNumber(),  // line number, or -1 if unknown  
                                 e.getColumnNumber() // column number, or -1 if unknown  
                 );  
 }  
   
 void Exception::provide_source(Pool& pool, const String *source, const SAXException& e) {  
         throw Exception(0, 0,  
                 source,  
                 "%s",  
                         pool.transcode_cstr(XalanDOMString(e.getMessage()))  // message for exception  
         );  
 }  
 void Exception::provide_source(Pool& pool, const String *source, const SAXParseException& e) {  
         throw Exception(0, 0,  
                 source,  
                 "%s. %s(%d:%d)",  
                         pool.transcode_cstr(XalanDOMString(e.getMessage())),  // message for exception  
                         e.getSystemId()?pool.transcode_cstr(XalanDOMString(e.getSystemId())):"block", // file of exception  
                         e.getLineNumber(), e.getColumnNumber() // line:col  
         );  
 }  
   
   
 void Exception::provide_source(Pool& pool, const String *source, const XMLException& e) {  
         throw Exception(0, 0,  
                 source,  
                 "%s (%s). %s(%d)'",   
                         pool.transcode_cstr(XalanDOMString(e.getMessage())),  // message for exception  
                         pool.transcode_cstr(XalanDOMString(e.getType())), // type of exception  
                           
                         e.getSrcFile()?e.getSrcFile():"block", // file of exception  
                         e.getSrcLine()  // line number  
                         //e.getCode()  
         );  
 }  }
   
 */  
 #endif  

Removed from v.1.29  
changed lines
  Added in v.1.43.2.15.2.4


E-mail: