--- parser3/src/main/pa_request.C 2001/03/24 10:54:46 1.73 +++ parser3/src/main/pa_request.C 2001/03/24 14:30:59 1.76 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.73 2001/03/24 10:54:46 paf Exp $ + $Id: pa_request.C,v 1.76 2001/03/24 14:30:59 paf Exp $ */ #include "pa_config_includes.h" @@ -39,7 +39,7 @@ Request::Request(Pool& apool, fclasses(apool), fdefault_lang(adefault_lang), flang(adefault_lang), info(ainfo), - fdefault_content_type(0), + default_content_type(0), used_files(apool) { // root superclass, @@ -161,7 +161,11 @@ void Request::core(const char *root_auto // $MAIN:defaults Value *defaults=main_class?main_class->get_element(*defaults_name):0; - fdefault_content_type=defaults?defaults->get_element(*content_type_name):0; + // value must be allocated on request's pool for that pool used on + // meaning constructing @see attributed_meaning_to_string + default_content_type=defaults? + defaults->get_element(*content_type_name) + :NEW VString(*NEW String(pool(), "text/html")); // execute @main[] const String *body_string=execute_method(*main_class, *main_method_name); @@ -179,9 +183,33 @@ void Request::core(const char *root_auto // OK. write out the result output_result(*body_string, header_only); } - CATCH(e) { + CATCH(e) { // request handling problem + // we're returning not result, but error explanation TRY { - // we're returning not result, but error explanation + // log the beast + const String *problem_source=e.problem_source(); + if(problem_source) + SAPI::log(pool(), +#ifndef NO_STRING_ORIGIN + "%s(%d): " +#endif + "'%s' %s [%s %s]", +#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():"-" + ); + else + SAPI::log(pool(), + "%s [%s %s]", + e.comment(), + e.type()?e.type()->cstr():"-", + e.code()?e.code()->cstr():"-" + ); // reset language to default flang=fdefault_lang; @@ -391,9 +419,7 @@ void Request::output_result(const String cookie.output_result(); // set default content-type - if(!fdefault_content_type) - fdefault_content_type=NEW VString(*NEW String(pool(), "text/html")); - response.fields().put_dont_replace(*content_type_name, fdefault_content_type); + response.fields().put_dont_replace(*content_type_name, default_content_type); // prepare header: $response:fields without :body response.fields().for_each(add_header_attribute, /*excluding*/ body_name);