--- parser3/src/main/pa_request.C 2004/10/05 10:55:36 1.271 +++ parser3/src/main/pa_request.C 2005/07/08 14:06:11 1.274 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REQUEST_C="$Date: 2004/10/05 10:55:36 $"; +static const char * const IDENT_REQUEST_C="$Date: 2005/07/08 14:06:11 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -271,6 +271,20 @@ const char* Request::get_exception_cstr( return result; } + +void Request::configure() { + // configure admin options if not configured yet + if(!configure_admin_done) + configure_admin(main_class); + + // configure not-admin=user options + methoded_array().configure_user(*this); + + // $MAIN:MIME-TYPES + if(Value* element=main_class.get_element(mime_types_name, main_class, false)) + if(Table *table=element->get_table()) + mime_types=table; +} /** load MAIN class, execute @main. MAIN class consists of all the auto.p files we'd manage to find @@ -337,25 +351,20 @@ gettimeofday(&mt[0],NULL); } } - // compile requested file - String& spath_translated=*new String; - spath_translated.append_help_length(request_info.path_translated, 0, String::L_TAINTED); - use_file(main_class, - spath_translated, - 0 /*main_alias*/, - true /*ignore class_path*/); - - // configure method_frame options if not configured yet - if(!configure_admin_done) - configure_admin(main_class); - - // configure not-method_frame=user options - methoded_array().configure_user(*this); - - // $MAIN:MIME-TYPES - if(Value* element=main_class.get_element(mime_types_name, main_class, false)) - if(Table *table=element->get_table()) - mime_types=table; + try { + // compile requested file + String& spath_translated=*new String; + spath_translated.append_help_length(request_info.path_translated, 0, String::L_TAINTED); + use_file(main_class, + spath_translated, + 0 /*main_alias*/, + true /*ignore class_path*/); + + configure(); + } catch(...) { + configure(); // configure anyway, useful in @unhandled_exception [say, if they would want to mail by SMTP something] + rethrow; + } #ifdef RESOURCES_DEBUG //measure:after compile @@ -429,8 +438,6 @@ t[9]-t[3] Request::Exception_details details=get_details(e); const char* exception_cstr=get_exception_cstr(e, details); - // log the beast - SAPI::log(sapi_info, "%s", exception_cstr); // reset language to default flang=fdefault_lang; @@ -499,11 +506,19 @@ body_string=&execute_method(frame, *meth VString body_vstring(*body_string); VFile* body_file=body_vstring.as_vfile(String::L_UNSPECIFIED, &charsets); + // conditionally log it + Value* vhandled=details.vhash.hash().get(exception_handled_part_name); + if(!vhandled || !vhandled->as_bool()) { + SAPI::log(sapi_info, "%s", exception_cstr); + } + // ERROR. write it out output_result(body_file, header_only, false); - } catch(const Exception& e) { + } catch(const Exception& e) { // exception in unhandled exception Request::Exception_details details=get_details(e); const char* exception_cstr=get_exception_cstr(e, details); + // unconditionally log the beast + SAPI::log(sapi_info, "%s", exception_cstr); throw Exception(0, 0, @@ -798,14 +813,17 @@ void Request::output_result(VFile* body_ Value* vfile_name=body_file->fields().get(name_name); if(!vfile_name) { vfile_name=body_file->fields().get(response_body_file_name); - const String& sfile_name=vfile_name->as_string(); + if(vfile_name) + { + const String& sfile_name=vfile_name->as_string(); - char* name_cstr=sfile_name.cstrm(); - if(char *after_slash=rsplit(name_cstr, '\\')) - name_cstr=after_slash; - if(char *after_slash=rsplit(name_cstr, '/')) - name_cstr=after_slash; - vfile_name=new VString(*new String(name_cstr)); + char* name_cstr=sfile_name.cstrm(); + if(char *after_slash=rsplit(name_cstr, '\\')) + name_cstr=after_slash; + if(char *after_slash=rsplit(name_cstr, '/')) + name_cstr=after_slash; + vfile_name=new VString(*new String(name_cstr)); + } } if(vfile_name) { const String& sfile_name=vfile_name->as_string();