Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion Issue using OnError

I am trying to replace my cferror tag(which was in application.cfm) with onError method (in application.cfc which will replace application.cfm). But I am facing an issue.
The issue is :

For onError, If i tried to display some user friendly message, it is being displayed in the html at the place where the error is occured.
For example, If exception is occured in the footer, then the message is displayed in the footer of the site and everything else(html) on the site is also displayed.
But when i was using cferror tag, If exception is occured, then only that template is being displayed which is specified in cferror tag.

So,
Is there any way to make the onError to work same as cferror tag?
(In sense of displaying user-friendly message)

Thanks.

like image 931
Waqas Malik Avatar asked Nov 24 '25 00:11

Waqas Malik


1 Answers

What you're describing makes sense. The output buffer is already part-filled with a response for the client.

In your onError method in application.cfc, you ought to be able to use <cfcontent reset=true> to empty the buffer, then you can send whatever response you like.

like image 142
barnyr Avatar answered Nov 27 '25 03:11

barnyr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!