Index: openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl,v diff -u -r1.32 -r1.33 --- openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 18 Nov 2017 12:06:40 -0000 1.32 +++ openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 9 Jan 2018 13:33:13 -0000 1.33 @@ -73,7 +73,7 @@ lreplace lreverse lsearch lset lsort namespace open package pid proc puts pwd read refchan regexp regsub rename return scan seek set socket source split string subst switch tell - time trace unload unset update uplevel upvar variable vwait + time trace try unload unset update uplevel upvar variable vwait while } @@ -100,7 +100,7 @@ set has_contract_p 0 if { ![file exists "$::acs::rootdir/$path"] } { - return -code error "File $path does not exist" + error "File $path does not exist" } set file [open "$::acs::rootdir/$path" "r"] @@ -121,24 +121,22 @@ doc_set_page_documentation_mode 1 #ns_log notice "Sourcing $::acs::rootdir/$path in documentation mode" - set errno [catch { source "$::acs::rootdir/$path" } error] - doc_set_page_documentation_mode 0 - - # - # In documentation mode, we expect ad_page_contract (and counterparts) - # to break out of sourcing with an error to avoid side-effects of sourcing - # - if { $errno == 1} { + ad_try { + # + # Sourcing in documentation mode fills "doc_elements" + # + source "$::acs::rootdir/$path" + } on error {errorMsg} { if {[regexp {^ad_page_contract documentation} $::errorInfo] } { - array set doc_elements $error + array set doc_elements $errorMsg } - if { [array exists doc_elements] } { - return [array get doc_elements] - } - return [list] + return -code error [array get doc_elements] + } finally { + doc_set_page_documentation_mode 0 } - return -code $errno -errorcode $::errorCode -errorinfo $::errorInfo $error + return [array get doc_elements] + } ad_proc -public api_script_documentation { @@ -175,8 +173,10 @@ return $out } - if { [catch { array set doc_elements [api_read_script_documentation $path] } error] } { - append out "

Unable to read $path: [ns_quotehtml $error]

\n" + ad_try { + array set doc_elements [api_read_script_documentation $path] + } on error {errorMsg} { + append out "

Unable to read $path: [ns_errorMsg $error]

\n" return $out } Index: openacs-4/packages/acs-api-browser/www/display-sql.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/www/display-sql.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-api-browser/www/display-sql.tcl 7 Aug 2017 23:47:46 -0000 1.6 +++ openacs-4/packages/acs-api-browser/www/display-sql.tcl 9 Jan 2018 13:33:13 -0000 1.7 @@ -65,9 +65,9 @@ set sql "" set fn [acs_package_root_dir $package_key]/sql/$url if {[file readable $fn]} { - if {[catch { + ad_try { set f [open $fn]; set sql [read $f]; close $f - } errorMsg]} { + } on error {errorMsg} { ad_return_warning "Problem reading file" "There was a problem reading $url ($errorMsg)" } } Index: openacs-4/packages/acs-api-browser/www/package-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/www/package-view.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-api-browser/www/package-view.tcl 18 Nov 2017 12:03:06 -0000 1.11 +++ openacs-4/packages/acs-api-browser/www/package-view.tcl 9 Jan 2018 13:33:13 -0000 1.12 @@ -135,7 +135,7 @@ unset doc_elements } # don't stop completely if the page is gone - if { [catch { + ad_try { set full_path "packages/$package_key/$path" array set doc_elements [api_read_script_documentation $full_path] @@ -166,12 +166,16 @@ } else { set content_type directory } - multirow append content_pages $indentation $full_path $content_type $name $type $first_sentence + multirow append content_pages \ + $indentation $full_path $content_type $name $type $first_sentence } set last_components $components - } error] } { - ns_log Error "API Broswer: Package View: $error" - # couldn't read info from the file. it probably doesn't exist. + } on error {errorMsg} } { + # + # Couldn't read info from the file. it probably doesn't exist. + # + ns_log Error "API Broswer: Package View: $errorMsg" + } } } Index: openacs-4/packages/acs-api-browser/www/proc-search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/www/proc-search.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-api-browser/www/proc-search.tcl 7 Aug 2017 23:47:46 -0000 1.16 +++ openacs-4/packages/acs-api-browser/www/proc-search.tcl 9 Jan 2018 13:33:13 -0000 1.17 @@ -118,9 +118,8 @@ ## Source Search: ################# if {$source_weight != 0} { - if {![catch {set source [info body $proc]}]} { - incr score [expr {$source_weight * [::apidoc::ad_keywords_score $query_string $source]}] - } + set body [api_get_body $proc] + incr score [expr {$source_weight * [::apidoc::ad_keywords_score $query_string $source]}] } #####