ad_try (public)

 ad_try [ -auto_abort ] body [ args... ]

Defined in packages/acs-tcl/tcl/exception-procs.tcl

Generic code for OpenACS to handle exceptions and traps based on Tcl's primitives. This implementation is a slight generalization of the Tcl 8.6 built-in ::try, which handles ad_script_aborts automatically. The command "ad_try" should replace the various exception handling constructs such as "catch", which tend to swallow often error conditions, making debugging unnecessarily hard. It will make "with_finally" and "with_catch" obsolete, which should be marked as deprecated in the not-to-far future.

Switches:
-auto_abort (optional, boolean, defaults to "true")
Parameters:
body (required)
See Also:
  • with_finally
  • with_catch

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) ad_try ad_try test_create_form_with_form_instance->ad_try Class ::xo::db::Class Class ::xo::db::Class (public) Class ::xo::db::Class->ad_try Class ::xo::db::CrClass Class ::xo::db::CrClass (public) Class ::xo::db::CrClass->ad_try Class ::xowiki::formfield::FormField Class ::xowiki::formfield::FormField (public) Class ::xowiki::formfield::FormField->ad_try Class ::xowiki::formfield::numeric Class ::xowiki::formfield::numeric (public) Class ::xowiki::formfield::numeric->ad_try Class ::xowiki::includelet::child-resources Class ::xowiki::includelet::child-resources (public) Class ::xowiki::includelet::child-resources->ad_try

Testcases:
create_form_with_form_instance
Source code:
        #
        # Per default, ad_script_abort exceptions are automatically passed
        # through the higher handlers, aborting all execution levels. Only
        # the top-level processor should handle these cases (probably
        # silently).
        #
        set extraTraps {}
        if {$auto_abort_p} {
            #
            # Add silent handling of "ad_script_abort" to
            # the traps.
            #
            lappend extraTraps  trap {AD EXCEPTION ad_script_abort} {result} {
                    ::throw {AD EXCEPTION ad_script_abort} $result
                }
        }
        #
        # Call the Tcl 8.6 built-in/compliant ::try in the scope of the caller
        #
        #puts stderr EXEC=[list ::try $body {*}$extraTraps {*}$args]

        tailcall ::try $body {*}$extraTraps {*}$args
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: