Does anyone have experience wrapping a legacy appl...
# box-products
d
Does anyone have experience wrapping a legacy application with ColdBox? ( https://www.ortussolutions.com/blog/coldbox-legacy-app-demo ) I can throw an error within a legacy template and get the expected error handler results. When throwing the same error within a Coldbox view template, the error becomes a server error rather than a simple exception.
j
Brad seems to... šŸ™‚ Can you use Application.cfc to catch the error to mediate the issue?
d
The Application.cfc onError() does not appear to execute when ColdBox is processing the error.
b
@davidrschaller To be clear, ColdBox has its own error handling routines that kick in
An error from inside a handler or view is NOT going to bubble all the way up to the Application.cfc's
onError()
method by design
d
Yes. @Patrick, I am following the Coldbox Legacy app.
b
That method is only the last-ditch-oh-crap-everything-fell-apart stop šŸ™‚
So I assume you're just seeing whatever error template is configured in ColdBox
If there's logic you're wanting to incorporate into your errors, there are several integraion points you can plug that in such as the onException interception point and the exception Handler which overrides even the custom error template in ColdBox
d
I discovered that Bootstrap.cfc line 646 and 651 has something to do with this. I commented them out and my error handling is working as expected. Strange!
b
Without really knowing what "this" is, it's hard to follow you
d
getPageContextResponse().setStatus( 500, "Internal Server Error" );
b
All I understand at this point is there's something about an error and it didn't make sense to you šŸ™‚
d
That is an obvious setting. šŸ™‚
Sorry Brad. So If I force an error .. #foo# .. when it doesn't exist, a Server 500 error is thrown in a CB view. I don't see a 500 error in a legacy cfm template.
This does happen on IIS .. of course, don't see this when serving locally via commandbox!
b
To be clear, there's no such thing as a "server 500 error". I assume you're conflating the status code of the HTTP response with the actual exception
Exceptions don't have status codes-- just a message, detail, and stack trace
Is your question why ColdBox sets the status code of the HTTP response to 500 when there is an exception?
d
My error page is showing this ...
addtionally, my custom error page is displayed after this message.
b
I think you're mixing several distinct problems together
There's • the status code of the response • The HTML of the response • what your browser is apparently seeing
I'm not sure exactly which if those three separate bullets are tripping you up-- perhaps all of them?
IIS is known for showing "friendly" error pages so I'd start there (bullet 3)
It's under the "error pages" feature settings
This is from an older IIS version
message has been deleted
Set that to "detailed errors" and see if it changes what you see
If it does, the simple explanation is probably just that your legacy site returned a 200 status code for errors and Coldbox returned a 500 status code and IIS behaved differently based on that status code.
It's also worth mentioning, ColdFusion has a setting that controls whether you want error pages to return a 200 or a 500. ColdBox probably should have something similar just since some people prefer to return a 200 to prevent malicious bots from detecting when they've caused an error. I think that's sort of dumb, but it's a common lockdown step.
d
Thanks for info. I'll continue to look into when CF is returning 200 for error pages. Basically, I'd like to eliminate the IIS message from this output. So, whatever it takes to turn that off.
b
@davidrschaller I showed you the IIS setting above that is likely the issue. Did you try changing as I suggested?
Should only take about 30 seconds to test this
d
I did review and it was set as you suggested.
b
Can you be more specific
What specifically was it set to and what specifically did you change the value to?
I didn't neccessarily show you what to change your setting to in my screenshot
I just took a random screenshot of whatever I happened to have it set to just to show you what the setting looks like
Did you set it to "detailed errors" and did you make sure you were editing the proper IIS set that corresponds with what you're developing on?
d
Ok. The form shows this ...
I didn't update, only brought it up for the current web context.
I've currently worked around the issue by: 1) Removing the line: 'getPageContextResponse().setStatus( 500, "Internal Server Error" );' in Bootsrap.cfc processException() and 2) Removing event.setHTTPHeader( statusCode = 500 ); from handler:Main.onException(). Maybe not how it should be done, but IIS no longer sees a '500 status'
b
@davidrschaller Is there a compelling reason why you're not setting it to the value I suggested?
Based on your setup, if this is an IIS installation on another server, then you're going to still be getting the "custom" errors
Which is why I suggested you change it to "detailed errors" in all cases to test this
hacking the Coldbox source code is not a proper workaround. That is going to get overwritten the next time you update ColdBox.
d
Brad, I totally missed the 'change setting to Detailed errors'!
I updated the setting and the IIS message is no longer displayed!
Thank you for getting me through this!
šŸ‘ 1