OracleConnection.Error + OracleException

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
tsv
Posts: 13
Joined: Fri 16 Jan 2009 06:11
Location: Kiev, Ukraine
Contact:

OracleConnection.Error + OracleException

Post by tsv » Thu 29 Dec 2011 09:09

Hi.

I need to to do some format operations with OracleException.Message parameter when DB exception occurs.
Where (or how) can I do it?
I decided to do it in OracleConnection.Error event but it doesn't throw exception after it to catch it in outer try..catch block :(
OracleException has no public constructor :(

Soft: Mobile Edition + CF2.0

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 04 Jan 2012 15:54

It is not a common practice to modify the message after the exception was thrown. As for the public constructor, there is none because only the dotConnect for Oracle runtime is supposed to throw OracleExceptions.

To modify the error message, you can wrap OracleException objects into exceptions of your own or standard types:

Code: Select all

catch (OracleException ex) {
  
  InvalidOperationException invalidOperation = 
    new InvalidOperationException(
      "The modified error message",
      ex
    );
  throw invalidOperation;
}

Post Reply