On Thu, 24 Oct 2002, Daniel P. Stasinski wrote:
> # ADP special pages
> #ns_param errorpage ${pageroot}/errorpage.adp ;# ADP error page.
>
> Does anyone have an example of how this is used?
If configured, it is automatically ns_adp_included when an TCL error
occurs in ADP (once for every error). It gets two args:
[24/Oct/2002:20:57:42][20736.12293][-conn3-] Notice: ERROR PAGE: argc: 2
argv0: full path to errorpage.adp
argv1: tcl error stack trace (global $errorInfo I suspect)
I use combination of startpage & errorpage to stop ADP script processing
if an error occurs and to present some friendly message to the user. I use
something like this:
###
# errorpage.adp
#
# truncate probably partial ADP output
ns_adp_trunc
global adp_error_p
set adp_error_p 1
ns_adp_break "ADP processing broken to avoid subsequent errors"
###
# startpage.adp
#
set status [catch {
# Sorry [ns_adp_argv 1] doesn't work unless you patch adp.c
set adp [ns_urltofilr [ns_conn url]]
ns_adp_include $adp
} result]
global adp_error_p
if { $status && [info exists adp_error_p] && $adp_error_p == 1 } {
# Sorry ns_adp_include error_msg.adp doesn't work
# because of ADP exception set by ns_adp_break in errorpage.adp
# We can use ns_puts anyway
ns_puts "Friendy error message"
}
--tkosiak