This would be nice...

Posts   
 
    
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 28-Jan-2005 00:57:39   

Hi, Frans. I was thinking it would be of great value if you would be willing to create custom exceptions that gave us more specific information regarding SQL errors that occur in the process of executing queries.

Examples:

ORMFieldNotNullableException - Thrown when attempting to perform an Insert or Update without a required field. Includes the name of the violated field.

ORMConstraintViolation - Thrown for a constraint violation. Includes the name of the constraint that was violated.

I know this will be a bit ugly as SQL itself doesn't give you specific error codes (I don't know about Oracle), but since the message texts themselves are consistent perhaps it could still be possible.

This would be of tremendous benefit, as identifying the specific problem will go a long way towards communicating back the issue to the user. Thanks for the consideration. simple_smile

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 28-Jan-2005 10:09:58   

I've considered this when developing the first version, but it was almost impossible to do. the reason for this is that Microsoft made a mistake with the ADO.NET exceptions: they didn't make distinctions. So the only way to find out what the real error was is by checking the error number returned in the exception. But because there is no standard exception for database errors, this is database specific AND the errorcodes are also database specific. This leads to a table with thousands of error codes, which are all different for each database.

The only thing I could do is to include the caught exception (for example SqlException) in the exception thrown (ORMQueryExecutionException) as the inner exception. So when you catch an ORMQueryExecutionException, you can rethrow the inner exception and catch the specific exception and handle the error code yourself, but it's a massive amount of work, converting an error code to something you can work with...

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 28-Jan-2005 22:58:53   

Bummer. So, there's virtually no chance of this happening? Any possibility of maybe hiring it out? The ROI might be worth something as seeing a feature like that in marketing propoganda would be pretty attractive.

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 29-Jan-2005 13:16:17   

I've to see what they've done in .NET 2.0 to this, I'm not sure if there is a little better exception model.

The amount of work is massive, don't underestimate the number of errors sqlserver or oracle can give you simple_smile But I've to check if these can be filtered out in groups (like if there are 20 or so error codes worth watching, the rest can be ignored, but I don't want to have a switch case statement with 1000s of entries wink )

I've put it on the todo so it's on the list of new things to consider for the upgrade of april/may

Frans Bouma | Lead developer LLBLGen Pro