Hi,
I have an Oracle stored procedure that will raise an application error under certain conditions. Ther actual errors raised may vary.
Whichever error I raise comes back as an OracleException. I have not found any 'number' property within the oracle exception to identify exactly which error was thrown by my stored procedure.
In the code below, I have included 3 examples - the first one I don't want to have to do, the second one seems more achievable and the third would be the ideal but I've no idea how to do.
Would be very gratefuul for any hints or tips.
Thanks,
Graeme
"Just beacuse you're paranoid, don't mean they're not after you
I have an Oracle stored procedure that will raise an application error under certain conditions. Ther actual errors raised may vary.
Whichever error I raise comes back as an OracleException. I have not found any 'number' property within the oracle exception to identify exactly which error was thrown by my stored procedure.
In the code below, I have included 3 examples - the first one I don't want to have to do, the second one seems more achievable and the third would be the ideal but I've no idea how to do.
Code:
// Example 1 - last resort
try{
db.ExecuteNonQuery(cmd);
} catch ( OracleException ex){
if (ex.Message == "MyCustomError1"){
// Do some stuff
} elseif (ex.Message == "MyCustomError2"){
// Do somethinf else
}
// and so on ...
}
// Example 2 - possible solution
// Not sure how to retrieve error number though
try{
db.ExecuteNonQuery(cmd);
} catch ( OracleException ex){
if (ex.Number == 1){
// Do some stuff
} elseif (ex.Number == 2){
// Do somethinf else
}
// and so on ...
}
// Example 3 - would really like to have this, but
// not sure how to map the custom oracle exception to
// my exception class
public class CustomException1 : Exception{
// Implementation ommitted
}
// Usage
try{
db.ExecuteNonQuery(cmd);
} catch ( CustomException1 ex){
// do something
} catch (CustomException2 ex){
// do something else
}
Would be very gratefuul for any hints or tips.
Thanks,
Graeme
"Just beacuse you're paranoid, don't mean they're not after you