differences with exceptions

69 views
Skip to first unread message

Phil Cruz

unread,
Aug 30, 2016, 12:10:46 PM8/30/16
to Lucee
I'm doing a try/catch around some code that inserts to the db. The catch looks like

catch(Any e) {
 
if ( e.NativeErrorCode EQ "2601") //Cannot insert duplicate key row

 
{
 
// do something
 
} else {
 rethrow
;
 
}
 
}


This works in ACF but fails in Lucee 5. When I dump the exception I see they are quite different.


Is that a bug?

Thanks,
Phil


Nando Breiter

unread,
Aug 30, 2016, 4:32:26 PM8/30/16
to lu...@googlegroups.com
Armchair opinion here, but I would not expect the exceptions in ACF and Lucee to be at all the same, because there would not be a specification or documentation of any kind that would indicate to the different development teams what messages each individual exception should return. You could file an enhancement request to make the exceptions the same, but I find that completely unrealistic. 

You could also file an enhancement request to make this specific exception the same, at least the NativeErrorCode bit. I have no idea how useful that might be to others.







Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

--
Get 10% off of the regular price for this years CFCamp in Munich, Germany (Oct. 20th & 21st) with the Lucee discount code Lucee@cfcamp. 189€ instead of 210€. Visit https://ti.to/cfcamp/cfcamp-2016/discount/Lucee@cfcamp
---
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+unsubscribe@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/ff864e80-9763-4e1d-91a2-12c0d89c348e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Jesse Shaffer

unread,
Aug 31, 2016, 11:33:55 AM8/31/16
to Lucee
What is the "type" on the lucee exception?  It is not visible from the screenshot.

Phil Cruz

unread,
Aug 31, 2016, 11:35:31 AM8/31/16
to Lucee

Jesse Shaffer

unread,
Aug 31, 2016, 11:45:29 AM8/31/16
to Lucee
It also looks like you're using ORM.  ACF appears to be passing through the JDBC exception, while Lucee is wrapping it in an Application exception.  Just as an experiment - can you try this on Lucee:

writedump(e.getCause());
writedump
(e.getSuppressed());

Phil Cruz

unread,
Sep 14, 2016, 4:18:02 PM9/14/16
to Lucee
Yes, I am using ORM. Here is a stripped down test case

<cfscript>
 try {
 activationCode = "B5FB4CACC332D842EF99BB06CE1DAA35";
 machineID = "TESTMACHINE1";
 act = EntityNew("Activation");
 sn = EntityLoadByPK("SerialNumber", 196941);
 act.setMachineID(machineID);
 act.setActivationCode(activationCode);
 act.setDateCreated(now());
 act.setActivationStatusID(1);
 act.setLastName("");
 act.setEmail("");
 act.setSerialNumber(sn);
 act.save();
 } catch (Any e)
 {
 writeDump(StructKeyList(e));
 //on ACF: "Suppressed,RootCause,StackTrace,Detail,Message,Cause,Type,TagContext"
 //on Lucee: "Extended_Info,Message,Detail,additional,TagContext,ErrorCode,type,StackTrace,ExtendedInfo"
 //writeDump(var=e, format="html");
 writeDump(var=e.getCause(), label="getCause");
 writeDump(var=e.getSuppressed(), label="getSuppressed");
 }
</cfscript>

That runs fine on ACF. On Lucee 5 it errors on e.getCause()  with "No matching Method/Function for Struct.getCause() found" and similar error for getSuppressed.


Thanks,
Phil
Reply all
Reply to author
Forward
0 new messages