Forum OpenACS Q&A: ad_return_complaint causes errors to be logged

Is ad_return_complaint supposed to cause an error in the server log? If I call this from a simple .tcl page:
  ad_return_complaint 1 fubar
I get this in the log:
[21/Jul/2011:17:20:42][25922.1088448832][-conn:edjustis::1] Warning: propagating abortion from www/test/error.tcl (status 200): 'Problem with Your Input')
[21/Jul/2011:17:20:42][25922.1088448832][-conn:edjustis::1] Warning: propagating abortion from packages/acs-tcl/lib/page-error.tcl (status 200): 'Problem with Your Input')
[21/Jul/2011:17:20:42][25922.1088448832][-conn:edjustis::1] Error: rp_report_error: Error rendering error page (!)
    while executing
"error ADP_ABORT "
    (procedure "adp_abort" line 2)
    invoked from within
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init tcl $__adp_stub
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 2)
    invoked from within
    invoked from within
"template::adp_parse packages/acs-tcl/lib/page-error {stacktrace ADP_ABORT\n\ \ \ \ while\ executing\n\"error\ ADP_ABORT\ \"\n\ \ \ \ (proced..."
    ("uplevel" body line 1)
    invoked from within
"uplevel [list template::adp_parse [template::util::url_to_file $template [ad_conn file]] $template_params]"
    (procedure "ad_parse_template" line 15)
    invoked from within
"ad_parse_template -params $params "/packages/acs-tcl/lib/page-error""
    invoked from within
"set rendered_page [ad_parse_template -params $params "/packages/acs-tcl/lib/page-error"]"
    ("uplevel" body line 2)
    invoked from within
"uplevel $body "
This seems to be caused by these lines, from the definition for ad_return_complaint:
    # raise abortion flag, e.g., for templating
    global request_aborted
    set request_aborted [list 200 "Problem with Your Input"]

Is this intentional? The docs for ad_return_complaint say that it should "Return a page complaining about the user's input (as opposed to an error in our software, for which ad_return_error is more appropriate)". This doesn't seem like a full error to me.

Since our existing application uses ad_return_complaint in many places, we'd like to continue using it. This is, however, creating a lot of noise in our error log.

We're open to suggestions. Thanks in advance for your replies.

Kind regards,
Justis Peters

Posted by Justis Peters on
Does anyone have input on this?
Posted by Justis Peters on
P.S. This started happening after we upgraded to OpenACS 5.6, with code that didn't create these sorts of errors in previous versions.
Posted by Brian Fenton on
Hi Justis

I'm afraid I can't be much help to you other than to confirm the problem on my installation too (but it's a much older version than 5.6).


Posted by Jeff Rogers on
Looking at the definitions of template::adp_abort and template::adp_parse, in particular the error handling block of the latter, the intent seems to be that calling adp_abort will cause the current template being processed to return nothing without raising an error, while letting actual errors propagate up. However, the implementation of template::adp_abort doesn't return an appropriate error code to get into the correct branch of the switch.

On my own installation I changed template:adp_abort to call "return -code 10 ADP_ABORT" rather than "error ADP_ABORT" as it currently does, which makes it behave as it seems it should.