--- parser3/src/main/pa_request.C 2002/03/18 15:29:46 1.195 +++ parser3/src/main/pa_request.C 2002/04/16 09:32:00 1.199 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: pa_request.C,v 1.195 2002/03/18 15:29:46 paf Exp $ + $Id: pa_request.C,v 1.199 2002/04/16 09:32:00 paf Exp $ */ #include "pa_sapi.h" @@ -63,10 +63,11 @@ Request::Request(Pool& apool, fconnection(0), classes_conf(apool), anti_endless_execute_recoursion(0), - trace(apool) + exception_trace(apool) #ifdef RESOURCES_DEBUG - ,sql_connect_time(0),sql_request_time(0) + , sql_connect_time(0),sql_request_time(0) #endif + , self(0), root(0), rcontext(0), wcontext(0) { // default charsets pool().set_source_charset(*utf8_charset); @@ -161,7 +162,7 @@ gettimeofday(&mt[0],NULL); if(Hash *charsets=vcharsets->get_hash(0)) charsets->for_each(load_charset); else - throw Exception(0, 0, + throw Exception("parser.runtime", &vcharsets->name(), "must be hash"); } @@ -239,7 +240,7 @@ gettimeofday(&mt[1],NULL); // execute @main[] const String *body_string=execute_virtual_method(*main_class, *main_method_name); if(!body_string) - throw Exception(0,0, + throw Exception("parser.runtime", 0, "'"MAIN_METHOD_NAME"' method not found"); @@ -312,25 +313,27 @@ t[9]-t[3] const String *problem_source=e.problem_source(); if(problem_source && problem_source->size()) SAPI::log(pool(), + "%s: " #ifndef NO_STRING_ORIGIN ORIGIN_FILE_LINE_FORMAT": " #endif - "'%s' %s [%s %s]", + "'%s' %s [%s]", + info.uri, #ifndef NO_STRING_ORIGIN problem_source->origin().file?problem_source->origin().file:"global", problem_source->origin().line, #endif problem_source->cstr(), e.comment(), - e.type()?e.type()->cstr():"-", - e.code()?e.code()->cstr():"-" + e.type()?e.type():"-" ); else SAPI::log(pool(), - "%s [%s %s]", + "%s: " + "%s [%s]", + info.uri, e.comment(), - e.type()?e.type()->cstr():"-", - e.code()?e.code()->cstr():"-" + e.type()?e.type():"-" ); // reset language to default @@ -349,10 +352,11 @@ t[9]-t[3] if(Junction *junction=value->get_junction()) if(const Method *method=junction->method) { // preparing to pass parameters to - // @exception[origin;source;comment;type;code;stack] + // @unhandled_exception[exception;stack] VMethodFrame frame(pool(), value->name(), *junction); frame.set_self(*main_class); + // $exception frame.store_param(method->name, &exception2vhash(pool(), e)); // $stack[^table::set{name origin}] Array& stack_trace_columns=*NEW Array(pool()); @@ -360,7 +364,7 @@ t[9]-t[3] stack_trace_columns+=NEW String(pool(), "file"); stack_trace_columns+=NEW String(pool(), "lineno"); Table& stack_trace=*NEW Table(pool(), 0, &stack_trace_columns); - Array_iter tracei(trace); + Array_iter tracei(exception_trace); while(tracei.has_next()) { Array& row=*NEW Array(pool()); @@ -407,15 +411,8 @@ t[9]-t[3] } printed+=snprintf(buf+printed, MAX_STRING-printed, "%s", e.comment()); - const String *type=e.type(); - if(type) { - printed+=snprintf(buf+printed, MAX_STRING-printed, " type: %s", - type->cstr()); - const String *code=e.code(); - if(code) - printed+=snprintf(buf+printed, MAX_STRING-printed, ", code: %s", - code->cstr()); - } + if(const char *type=e.type()) + printed+=snprintf(buf+printed, MAX_STRING-printed, " type: %s", type); // future $response:content-type response.fields().put(*content_type_name, @@ -463,16 +460,16 @@ VStateless_class *Request::use_file(cons break; // found along class_path } } else - throw Exception(0, 0, + throw Exception("parser.runtime", &element->name(), "must be string or table"); if(!file_spec) - throw Exception(0, 0, + throw Exception("parser.runtime", &file_name, "not found along " MAIN_CLASS_NAME ":" CLASS_PATH_NAME); } if(!file_spec) - throw Exception(0, 0, + throw Exception("parser.runtime", &file_name, "usage failed - no " MAIN_CLASS_NAME ":" CLASS_PATH_NAME " were specified"); } @@ -588,7 +585,7 @@ const String& Request::mime_type_of(cons if(const String *result=mime_types->item(1)) return *result; else - throw Exception(0, 0, + throw Exception("parser.runtime", mime_types->origin_string(), "MIME-TYPE table column elements must not be empty"); }