--- parser3/src/include/pa_request.h 2026/04/25 13:38:46 1.272 +++ parser3/src/include/pa_request.h 2026/09/25 12:55:42 1.274 @@ -8,32 +8,23 @@ #ifndef PA_REQUEST_H #define PA_REQUEST_H -#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.272 2026/04/25 13:38:46 moko Exp $" +#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.274 2026/09/25 12:55:42 moko Exp $" #include "pa_pool.h" #include "pa_hash.h" #include "pa_wcontext.h" #include "pa_value.h" +#include "pa_vhash.h" #include "pa_stack.h" #include "pa_request_info.h" #include "pa_request_charsets.h" #include "pa_sapi.h" -// defines for externs - -#define EXCEPTION_HANDLED_PART_NAME "handled" - - // externs extern const String main_method_name; extern const String auto_method_name; -extern const String::Body exception_type_part_name; -extern const String::Body exception_source_part_name; -extern const String::Body exception_comment_part_name; -extern const String::Body exception_handled_part_name; - // defines for statics #define MAIN_CLASS_NAME "MAIN" @@ -54,6 +45,7 @@ class VResponse; class VCookie; class VStateless_class; class VConsole; +class VException; extern int pa_loop_limit; extern int pa_array_limit; @@ -70,6 +62,7 @@ class Request: public PA_Object { friend class Temp_recursion; friend class Request_context_saver; friend class Exception_trace; + friend class VException; public: class Trace { @@ -125,6 +118,7 @@ private: size_t bottom_index() { return fbottom; } void set_bottom_index(size_t abottom) { fbottom=abottom; } element_type bottom_value() { return get(bottom_index()); } + void set_range(size_t bottom, size_t top) { fbottom=bottom; fsize=top; } void clear() { fsize=fbottom=0; @@ -134,7 +128,7 @@ private: return fsize==fbottom; } - Table &table(Request &r); + Table &table(Request &r, const String* problem_source); }; ///@{ core data @@ -156,9 +150,9 @@ private: /// execution stack Stack stack; +public: /// exception stack trace Exception_trace exception_trace; -public: bool allow_class_replace; @@ -182,14 +176,7 @@ private: public: uint register_file(String::Body file_spec); - struct Exception_details { - const Operation::Origin origin; - const String* problem_source; - VHash& vhash; - Exception_details(const Operation::Origin aorigin, const String* aproblem_source, VHash& avhash): origin(aorigin), problem_source(aproblem_source), vhash(avhash) {} - }; - Exception_details get_details(const Exception& e); - const char* get_exception_cstr(const Exception& e, Exception_details& details); + const char* get_exception_cstr(const Exception& e, VException& details); /// @see Stack::wipe_unused void wipe_unused_execution_stack() { @@ -433,13 +420,28 @@ private: void output_result(VFile* body_file, bool header_only, bool as_attachment); }; +/// Hash-compatible exception; hash is built on demand. +class VException: public VHashReference { + Exception fexception; + String::Body ffile; + Value* fhandled; +public: + Operation::Origin origin; + const String* problem_source; + + VException(Request& r, const Exception& e); + + override HashStringValue& hash(); + override Value* get_element(const String& name); + override const VJunction* put_element(const String& name, Value* value); + + Value* handled(); +}; + /// Auto-object used to save request context across ^try body class Request_context_saver { Request& fr; - /// exception stack trace - size_t exception_trace_top; - size_t exception_trace_bottom; /// execution stack size_t stack; uint anti_endless_execute_recursion; @@ -455,8 +457,6 @@ class Request_context_saver { public: Request_context_saver(Request& ar) : fr(ar), - exception_trace_top(ar.exception_trace.top_index()), - exception_trace_bottom(ar.exception_trace.bottom_index()), stack(ar.stack.top_index()), anti_endless_execute_recursion(ar.anti_endless_execute_recursion), method_frame(ar.method_frame), @@ -465,8 +465,6 @@ public: flang(ar.flang), fconnection(ar.fconnection) {} void restore() { - fr.exception_trace.set_top_index(exception_trace_top); - fr.exception_trace.set_bottom_index(exception_trace_bottom); fr.stack.set_top_index(stack); fr.anti_endless_execute_recursion=anti_endless_execute_recursion; fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext;