Diff for /parser3/src/main/pa_exception.C between versions 1.25 and 1.63

version 1.25, 2001/11/15 18:21:31 version 1.63, 2024/11/04 03:53:25
Line 1 Line 1
 /** @file  /** @file
         Parser: exception class.          Parser: exception class.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)          Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
   
         $Id$  
 */  */
   
 #include "pa_common.h"  #include "pa_common.h"
 #include "pa_exception.h"  #include "pa_exception.h"
   #include "pa_sapi.h"
   #include "pa_globals.h"
   
   volatile const char * IDENT_PA_EXCEPTION_C="$Id$" IDENT_PA_EXCEPTION_H;
   
   // methods
   
 Exception::Exception() {  Exception::Exception(): ftype(0), fproblem_source(0), fcomment(0) {}
         ftype=fcode=fproblem_source=0;  
         fcomment[0]=0;  Exception::Exception(const Exception& src):
           ftype(src.ftype),
           fproblem_source(src.fproblem_source),
           fcomment(src.fcomment) {
 }  }
 Exception::Exception(const String *atype, const String *acode,  
                                           const String *aproblem_source,   Exception& Exception::operator =(const Exception& src) {
                                           const char *comment_fmt, ...) {          ftype=src.ftype;
         //_asm int 3;          fproblem_source=src.fproblem_source;
           fcomment=src.fcomment;
           return *this;
   }
   
   Exception::Exception(const char* atype, const String* aproblem_source, const char* comment_fmt, ...) {
         ftype=atype;          ftype=atype;
         fcode=acode;          fproblem_source=aproblem_source ? new String(*aproblem_source) : 0;
         fproblem_source=aproblem_source;  
   
         if(comment_fmt) {          if(!comment_fmt) {
                   fcomment=0;
           } else if (!strcmp(comment_fmt, "%s")) { // to avoid MAX_STRING limit
                 va_list args;                  va_list args;
                 va_start(args, comment_fmt);                  va_start(args, comment_fmt);
                 vsnprintf(fcomment, MAX_STRING, comment_fmt, args);                  fcomment=va_arg(args, const char *);
                   fcomment=fcomment ? pa_strdup(fcomment) : 0;
                 va_end(args);                  va_end(args);
         } else           } else {
                 fcomment[0]=0;                  char comment[MAX_STRING];
 }                  va_list args;
                   va_start(args, comment_fmt);
 #ifdef XML                  fcomment=pa_strdup(comment, vsnprintf(comment, MAX_STRING, comment_fmt, args));
 void Exception::provide_source(Pool& pool, const String *source, const XSLException& e) {                  va_end(args);
         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::add_comment(const char* acomment) {
 void Exception::provide_source(Pool& pool, const String *source, const XMLException& e) {          if(acomment)
         throw Exception(0, 0,                  fcomment=pa_strcat(fcomment, acomment);
                 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()  
         );  
 }  }
   
 void Exception::provide_source(Pool& pool, const String *source, const XalanDOMException& e) {  const String* Exception::problem_source() const {
         const char *s;          return fproblem_source && !fproblem_source->is_empty() ? fproblem_source : 0;
         int code=(int)e.getExceptionCode();  
         switch(code) {  
         case 1: s="INDEX_SIZE_ERR"; break;  
         case 2: s="DOMSTRING_SIZE_ERR"; break;  
         case 3: s="HIERARCHY_REQUEST_ERR"; break;  
         case 4: s="WRONG_DOCUMENT_ERR"; break;  
         case 5: s="INVALID_CHARACTER_ERR"; break;  
         case 6: s="NO_DATA_ALLOWED_ERR"; break;  
         case 7: s="NO_MODIFICATION_ALLOWED_ERR"; break;  
         case 8: s="NOT_FOUND_ERR"; break;  
         case 9: s="NOT_SUPPORTED_ERR"; break;  
         case 10: s="INUSE_ATTRIBUTE_ERR"; break;  
         case 11: s="INVALID_STATE_ERR"; break;  
         case 12: s="SYNTAX_ERR"; break;  
         case 13: s="INVALID_MODIFICATION_ERR"; break;  
         case 14: s="NAMESPACE_ERR"; break;  
         case 15: s="INVALID_ACCESS_ERR"; break;  
         case 201: s="UNKNOWN_ERR"; break;  
         case 202: s="TRANSCODING_ERR"; break;  
         default: s="<UNKNOWN CODE>"; break;  
         }  
         throw Exception(0, 0,  
                 source,  
                 "XalanDOMException %s (%d)",  
                         s,  // decoded code of exception  
                         code // code of exception  
         );  
 }  }
 #endif  

Removed from v.1.25  
changed lines
  Added in v.1.63


E-mail: