Catching more that one exception type in a single cfcatch block?

47 views
Skip to first unread message

AWDSOFT

unread,
Nov 11, 2015, 4:11:47 PM11/11/15
to Lucee
Hi Everyone,

This is something I've always wondered but have not found a solid answer for. I've always felt like something like this should be possible:

<cftry>
   
<cfthrow type="something" message="Error!">
   
<cfcatch type="application, something">Do stuff!</cfcatch>
</cftry>

In ACF you can't do that but is there any Lucee-magic that would enable something like this? I know I could just catch "any" and sort it all out within that block but the example above just feels so clean and nice.

Thanks!

AJ Mercer

unread,
Nov 11, 2015, 10:45:46 PM11/11/15
to lu...@googlegroups.com
try this

<cftry>
    <cfthrow type="something" message="Error!">
    <cfcatch type="application" >Do stuff!</cfcatch>
<cfcatch type="something">Do something!</cfcatch>
</cftry>

--
Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/c62028bf-c540-4372-baa9-76d9b7a1d203%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

AWDSOFT

unread,
Nov 12, 2015, 1:13:23 PM11/12/15
to Lucee
@AJ - That does work but it means I either have to duplicate the error handling for each "cfcatch" block or I have to abstract it into some other method. I'm really not a fan of duplicating the handling in each block so that leaves abstraction. While abstraction will do the trick, I just wanted to ask about the "awesome & clean" option first in case I missed a feature.
Reply all
Reply to author
Forward
0 new messages