I get a Exception type using
catch(Exception e){
log.Error(e.GetType()); // it write 'System.Data.EntityException'
}
so I change my code to catch that exception,
try{
...
}catch(EntityException a){
// need to do something
log.Error("I got it!");
}catch(Exception e){
log.Error("No");
}
and the code write only "No".
How can I catch the EntityException before reach Exception?
Thanks
The code you have should work correctly, provided there isn't another EntityException
type defined within the current set of using statements for that file or namespace.
Try fully qualifying the type, as in the following:
try{
...
}catch(System.Data.EntityException a){
// need to do something
log.Error("I got it!");
}catch(Exception e){
log.Error("No");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With