Index: openacs-4/packages/acs-tcl/tcl/exception-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/exception-procs.tcl,v diff -u -r1.11.2.5 -r1.11.2.6 --- openacs-4/packages/acs-tcl/tcl/exception-procs.tcl 28 Dec 2022 09:25:22 -0000 1.11.2.5 +++ openacs-4/packages/acs-tcl/tcl/exception-procs.tcl 28 Aug 2024 06:31:06 -0000 1.11.2.6 @@ -153,6 +153,40 @@ } } +ad_proc ad_unless_script_abort { + body + non_abort_action +} { + + Execute the provided body in the callers' environment. When the + body does not raise an "ad_script_abort" exception, the + "non_abort_action" is also executed. This pattern is useful when + handling client requests and where the "non_abort_action" is used + to return results to the client. When "ad_script_abort" is + executed, the connection is usually closed, and any attempt to + talk to the client over the closed connection will fail. + + The handling of script_abort exceptions is done usually in the + request processor. The function is useful when registering own + request procs (e.g., via "ns_register_proc") where the OpenACS + request processor is not involved. + + @param body script, which is always executed + @param non_abort_action script, which is executed unless the + body was aborted. + + @see ad_script_abort +} { + ad_try -auto_abort=false { + uplevel $body + } trap {AD EXCEPTION ad_script_abort} {r} { + # do nothing + } on ok RESULT { + uplevel $non_abort_action + } +} + + # Local variables: # mode: tcl # tcl-indent-level: 4