In Lucee 5.4, if I want the original exception thr...
# lucee
d
In Lucee 5.4, if I want the original exception thrown by a Java library, is this the "correct" way to do it?
cfcatch.getPageException().getException()
It gets me what I need, but just wanted to verify there was not a better way.
z
if it works
d
It does work, just wasn't sure if that path was really the "official" way to get the original exception or not. I'm working with a library that includes some details in the exception object, which is why I need it. It sure feels like the native exception should expose a getCause() or something to reveal the original exception.
z
With 6 you have the cause attribute for throw, so you can add your own context to the exception https://docs.lucee.org/reference/tags/throw.html#attribute-cause
that's basically what pageException is
d
That wouldn't be helpful in this case, because I'm trying to capture information from the original exception to format some data.
(I'm capture the exception to log and return in a validation method)
That's good to know that's available though. I can't tell you how many times I've wanted to throw a custom exception in my code, but return the original exception too.
💯 1
z
d
Nice!
z
@micha has been adding some DX stuff to cfml, which he misses from java
b
That's what I use, but keep in mind it won't work in Adobe
Adobe doesn't wrap their native exceptions in most cases so you can just use it directly