differences with exceptions

69 vues
Accéder directement au premier message non lu

Phil Cruz

non lue,
30 août 2016, 12:10:4630/08/2016
à 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

non lue,
30 août 2016, 16:32:2630/08/2016
à 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.

Le message a été supprimé

Jesse Shaffer

non lue,
31 août 2016, 11:33:5531/08/2016
à Lucee
What is the "type" on the lucee exception?  It is not visible from the screenshot.

Phil Cruz

non lue,
31 août 2016, 11:35:3131/08/2016
à Lucee

Jesse Shaffer

non lue,
31 août 2016, 11:45:2931/08/2016
à 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

non lue,
14 sept. 2016, 16:18:0214/09/2016
à 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
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message