Jason Ryan
02/10/2022, 9:21 PMApplication.cfc
onError
function? I have an isProduction()
function and was hoping I could only enable the error-trapping and re-routing functionality conditionally based on that. It doesn't quite seem to work that way when NOT in prod. It just swallows up errors and doesn't display anything on the page, unless the function is commented out.Tim
02/10/2022, 9:29 PMonError(any exception) {
if( !isProduction() ) {
rethrow;
}
}
In reality, what I have is more like:
onError(any exception) {
log(exception);
if( !isProduction() ) {
writeDump(exception);
}
}
Jason Ryan
02/10/2022, 9:30 PMJason Ryan
02/10/2022, 9:35 PMMatt Dyer
02/10/2022, 9:52 PMJason Ryan
02/10/2022, 10:10 PMAdam Cameron
It doesn't quite seem to work that way when NOT in prod.It's pretty hard to comment on why your code is not working the way you want if we're just left to guess what it is 😉 Also:
Yeah, it doesn't work.What does "doesn't work" mean in this context? What does it do? And how does that vary from what you expected?
Adam Cameron
onError
receives an exception object, then rethrow
is not gonna work I think, as that's pretty much designed to work in a try
/ catch
construct. If you have an exception object, you can just throw it.
onError(any exception) {
if( !isProduction() ) {
throw(object=exception);
}
}
That should work? If it doesn't can you pls give us more to go on than "Yeah, it doesn't work" this time around :-pTim
02/10/2022, 11:02 PMJason Ryan
02/11/2022, 3:22 PMAdam Cameron
onError
handler itself `try`/`catch`ed with just a final fallback to just a writeLog
entry, and a rethrow
Jason Ryan
02/11/2022, 8:53 PMMichael Gillespie
02/11/2022, 11:46 PMMichael Gillespie
02/11/2022, 11:46 PM