Index: openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl,v diff -u -r1.84 -r1.85 --- openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl 22 Dec 2017 13:51:55 -0000 1.84 +++ openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl 24 Dec 2017 12:28:07 -0000 1.85 @@ -346,7 +346,9 @@ if {$m<$max} {set max $m} ::xotcl::Object log "### Call Stack (level: command)" for {set i 0} {$i < $max} {incr i} { - if {[catch {set s [uplevel $i self]} msg]} { + try { + set s [uplevel $i self] + } on error {errorMsg} { set s "" } ::xotcl::Object log "### [format %5d -$i]:\t$s [info level [expr {-$i}]]" @@ -507,10 +509,12 @@ continue } #ns_log notice "*** cleanup $cmd" - if {[catch {eval $cmd} errorMsg]} { + try { + {*}$cmd + } on error {errorMsg} { set obj [lindex $cmd 0] ns_log error "Error during ::xo::cleanup: $errorMsg $::errorInfo" - catch { + try { ns_log notice "... analyze: cmd = $cmd" ns_log notice "... analyze: $obj is_object? [::xotcl::Object isobject $obj]" ns_log notice "... analyze: class [$obj info class]" @@ -534,7 +538,9 @@ } } #ns_log notice "*** at_end $at_end" - if {[catch {eval $at_end} errorMsg]} { + try { + {*}$at_end + } on error {errorMsg} { ns_log notice "Error during ::xo::cleanup: $errorMsg $::errorInfo" } array unset ::xo::cleanup @@ -811,7 +817,9 @@ if {[nsv_exists broadcast $tid]} { foreach cmd [nsv_get broadcast $tid] { ns_log notice "broadcast received {$cmd}" - if {[catch $cmd errorMsg]} { + try { + {*}$cmd + } on error {errorMsg} { ns_log notice "broadcast receive error: $errorMsg for cmd $cmd" } } Index: openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl,v diff -u -r1.112 -r1.113 --- openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl 22 Dec 2017 13:51:55 -0000 1.112 +++ openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl 24 Dec 2017 12:28:07 -0000 1.113 @@ -367,10 +367,12 @@ if {$args ne ""} { lassign $args op on_error_code set result "" - if {$op ne "on_error"} {error "only 'on_error' as argument after script allowed"} - if {[catch { + if {$op ne "on_error"} { + error "only 'on_error' as argument after script allowed" + } + try { set result [:uplevel [list ::dbi_eval -transaction committed $script]] - }]} { + } on error {$errorMsg} { :uplevel $on_error_code } return $result @@ -665,11 +667,12 @@ # we can obtain a session_id from the the db driver. If we can't, # we fall back to a per request-cache (via toplevel variable). # - catch {set session_id [ns_db session_id $handle]} - if {[info exists session_id]} { + try { + set session_id [ns_db session_id $handle] + } on ok {r} { #ns_log notice "=== $handle $session_id" set varName ::xo::prepared($session_id,$key) - } else { + } on error {errorMsg} { set session_id "-" set varName __prepared($key) } @@ -735,7 +738,9 @@ # Unfortunately, ns_cache has no command to check, whether # a cache exists, so we use the little catch below to check. # - if {[catch {ns_cache flush xotcl_object_cache NOTHING}]} { + try { + ns_cache flush xotcl_object_cache NOTHING + } on error {errorMsg} { ns_log notice "xotcl-core: creating xotcl-object caches" if {[info commands ns_cache_create] ne ""} { @@ -1208,7 +1213,9 @@ } append slots $cmd \n } - if {[catch {$classname slots $slots} errorMsg]} { + ad_try { + $classname slots $slots + } on error {errorMsg} { error "Error during slots: $errorMsg" } @@ -2211,8 +2218,10 @@ -creation_ip $creation_ip \ ""] #[self class] set during_fetch 1 - if {[catch {:create ::$id {*}$args} errorMsg]} { - ad_log error $errorMsg + ad_try { + :create ::$id {*}$args + } on error {errorMsg} { + ad_log error "create fails: $errorMsg" } #[self class] unset during_fetch :initialize_acs_object ::$id $id @@ -2258,7 +2267,7 @@ Otherwise, objects are created with the XOTcl "new" method to avoid object name clashes. @param destroy_on_cleanup If this flag is true, the objects (and ordered composite) - will be automatically destroyed on cleaup (typically after the request was processed). + will be automatically destroyed on cleaup (typically after the request was processed). @param initialize can be used to avoid full initialization, when a large series of of objects is loaded. Per default, these objects @@ -2317,7 +2326,9 @@ ns_log warning "[namespace tail [$o info class]] $o has no package_id and no object_package_id" } } - if {[catch {$o initialize_loaded_object} errorMsg]} { + ad_try { + $o initialize_loaded_object + } on error {errorMsg} { ns_log error "$o initialize_loaded_object => [$o info vars] -> $errorMsg" } } Index: openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl,v diff -u -r1.25 -r1.26 --- openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 13 Dec 2017 20:42:31 -0000 1.25 +++ openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 24 Dec 2017 12:28:07 -0000 1.26 @@ -92,18 +92,24 @@ [self class]::ChildManager instvar composite # push the active composite lappend composite [self] - # check, if we have Tcl's apply available - if {$::tcl_version >= 8.5 && [info procs ::apply] eq ""} { - set errorOccurred [catch {::apply [list {} $cmds [self]]} errorMsg] + set errorOccurred 0 + # check, if we have Tcl's apply available + if {[info procs ::apply] eq ""} { + set applyCmd [list ::apply [list {} $cmds [self]]] } else { - set errorOccurred [catch {namespace eval [self] $cmds} errorMsg] + set applyCmd [list namespace eval [self] $cmds] } + try { + {*}$applyCmd + } on error {errorMsg} { + set errorOccurred 1 + } finally { + # pop the last active composite + set composite [lrange $composite 0 end-1] - # pop the last active composite - set composite [lrange $composite 0 end-1] - - if {$insert} { - Object instmixin delete [self class]::ChildManager + if {$insert} { + Object instmixin delete [self class]::ChildManager + } } if {$errorOccurred} {error $errorMsg} } Index: openacs-4/packages/xotcl-core/tcl/30-widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/30-widget-procs.tcl,v diff -u -r1.60 -r1.61 --- openacs-4/packages/xotcl-core/tcl/30-widget-procs.tcl 22 Dec 2017 13:51:55 -0000 1.60 +++ openacs-4/packages/xotcl-core/tcl/30-widget-procs.tcl 24 Dec 2017 12:28:07 -0000 1.61 @@ -365,15 +365,19 @@ # proc get_user_name {uid} { if {$uid ne "" && $uid != 0} { - if {[catch {acs_user::get -user_id $uid -array user}]} { + ad_try { + acs_user::get -user_id $uid -array user + } on error {errorMsg} { # we saw some strange cases, where after a regression, # a user_id was present, which was already deleted... - return [_ xotcl-core.nobody] + set result [_ xotcl-core.nobody] + } on ok {r} { + set result "$user(first_names) $user(last_name)" } - return "$user(first_names) $user(last_name)" } else { - return [_ xotcl-core.nobody] + set result [_ xotcl-core.nobody] } + return $result } # Index: openacs-4/packages/xotcl-core/tcl/chat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/Attic/chat-procs.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/packages/xotcl-core/tcl/chat-procs.tcl 13 Dec 2017 20:42:31 -0000 1.29 +++ openacs-4/packages/xotcl-core/tcl/chat-procs.tcl 24 Dec 2017 12:28:07 -0000 1.30 @@ -152,7 +152,7 @@ # was 1200 if {$ago > 300} { :logout -user_id $user -msg "auto logout" - catch {::bgdelivery do ::Subscriber sweep chat-[:chat_id]} + try {::bgdelivery do ::Subscriber sweep chat-[:chat_id]} } } :log "-- ending" @@ -168,13 +168,13 @@ # This values could already not be here. Just ignore when we don't # find them - catch { + try { ::xo::clusterwide nsv_unset -nocomplain ${:array}-login $user_id } - catch { + try { ::xo::clusterwide nsv_unset -nocomplain ${:array}-color $user_id } - catch { + try { ::xo::clusterwide nsv_unset -nocomplain ${:array}-last-activity $user_id } } Index: openacs-4/packages/xotcl-core/tcl/cluster-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/cluster-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/xotcl-core/tcl/cluster-procs.tcl 13 Dec 2017 20:42:31 -0000 1.11 +++ openacs-4/packages/xotcl-core/tcl/cluster-procs.tcl 24 Dec 2017 12:28:07 -0000 1.12 @@ -74,10 +74,12 @@ set addr [lindex [ns_set iget [ns_conn headers] x-forwarded-for] end] if {$addr eq ""} {set addr [ns_conn peeraddr]} #ns_log notice "--cluster got cmd='$cmd' from $addr" - if {[catch {set result [::xo::Cluster execute [ns_conn peeraddr] $cmd]} errorMsg]} { + ad_try { + set result [::xo::Cluster execute [ns_conn peeraddr] $cmd] + } on error {errorMsg} { ns_log notice "--cluster error: $errorMsg" ns_return 417 text/plain $errorMsg - } else { + } on ok {r} { #ns_log notice "--cluster success $result" ns_return 200 text/plain $result } Index: openacs-4/packages/xotcl-core/tcl/context-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/context-procs.tcl,v diff -u -r1.69 -r1.70 --- openacs-4/packages/xotcl-core/tcl/context-procs.tcl 13 Dec 2017 20:42:31 -0000 1.69 +++ openacs-4/packages/xotcl-core/tcl/context-procs.tcl 24 Dec 2017 12:28:07 -0000 1.70 @@ -248,8 +248,10 @@ if {[ns_conn isconnected]} { # This can be called, before ad_conn is initialized. # Since it is not possible to pass the user_id and ad_conn barfs - # when it tries to detect it, we use the catch and reset it later - if {[catch {set locale [lang::conn::locale -package_id $package_id]}]} { + # when it tries to detect it, we try to get it and reset it later + ad_try { + set locale [lang::conn::locale -package_id $package_id] + } on error {errorMsg} { set locale en_US } } else { @@ -273,9 +275,7 @@ -actual_query $actual_query \ -locale $locale \ [list -parameter_declaration $parameter] - #if {$package_id ne ""} { - # ::xo::cc package_id $package_id - #} + ::xo::cc package_id $package_id ::xo::cc set_user_id $user_id ::xo::cc process_query_parameter @@ -301,8 +301,10 @@ if {$user_id == -1} { ;# not specified if {[info exists ::ad_conn(user_id)]} { set :user_id [ad_conn user_id] - if {[catch {set :untrusted_user_id [ad_conn untrusted_user_id]}]} { - set :untrusted_user_id [:user_id] + ad_try { + set :untrusted_user_id [ad_conn untrusted_user_id] + } on error {errorMsg} { + set :untrusted_user_id ${:user_id} } } else { set :user_id 0 @@ -347,12 +349,12 @@ } else { # for requests bypassing the ordinary connection setup (resources in oacs 5.2+) # we have to get the user_id by ourselves - if { [catch { + ad_try { set cookie_list [ad_get_signed_cookie_with_expr "ad_session_id"] set cookie_data [split [lindex $cookie_list 0] {,}] set untrusted_user_id [lindex $cookie_data 1] set :requestor $untrusted_user_id - } errmsg] } { + } on error {errorMsg } { set :requestor 0 } } Index: openacs-4/packages/xotcl-core/tcl/cr-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/cr-procs.tcl,v diff -u -r1.58 -r1.59 --- openacs-4/packages/xotcl-core/tcl/cr-procs.tcl 22 Dec 2017 13:51:55 -0000 1.58 +++ openacs-4/packages/xotcl-core/tcl/cr-procs.tcl 24 Dec 2017 12:28:07 -0000 1.59 @@ -546,8 +546,10 @@ } { :get_context package_id creation_user creation_ip #my log "ID [self] create $args" - if {[catch {set p [:create ::0 {*}$args]} errorMsg]} { - ad_log error $errorMsg + ad_try { + :create ::0 {*}$args + } on error {errorMsg} { + ad_log error "CrClass create raises: $errorMsg" } #my log "ID [::0 serialize]" set item_id [::0 save_new \ Index: openacs-4/packages/xotcl-core/www/admin/toggle-debug.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/www/admin/toggle-debug.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/xotcl-core/www/admin/toggle-debug.tcl 7 Aug 2017 23:48:30 -0000 1.2 +++ openacs-4/packages/xotcl-core/www/admin/toggle-debug.tcl 24 Dec 2017 12:28:07 -0000 1.3 @@ -57,9 +57,11 @@ } set cmd [list {*}$scope ::nsf::method::property $obj {*}$modifier $method debug [expr {!$debug_p}]] ns_log notice "setting debug flag with cmd\n$cmd" -if {[catch {ns_eval {*}$cmd} errorMsg] } { +ad_try { + ns_eval {*}$cmd +} on error {errorMsg} { ns_log notice "toggle-debug raised error: $errorMsg" } -ns_log notice "calling return redirect to $return_url" +ns_log notice "calling return redirect to $return_url" ad_returnredirect $return_url