AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

DataBase Errors Result in Unhandled Exceptions #526

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Plinko now supports custom stored prodcedures (C,U&D) as of r2019.

Great !

However - 

Errors and Exceptions Generated by the DataBase Return As
Unhandled Exceptions and result in the runtime 'Yellow screen of Death'
in the base.SubmitChanges call.

Microsoft's Dave Ebbo has a great blog on how to handle Database Errors
as ValidationExceptions which results in a much more friendly user experience. 
(http://blogs.msdn.com/b/davidebb/archive/2008/12/11/handling-database-exception
s-in-dynamic-data.aspx).

Ebbo fills out handling with optional parameters such as 'can display'
etc... but in short 

 catch (Exception ex)
            {
                throw (new ValidationException(null, ex));
            }
does the trick.

The problem is I cannot find a way to hook into the the template submit logic 
to handle the general exception returned with a mor custom exception.

Is it possable to enhance the Plinko template to provide a exception override ??

__fred

Original issue reported on code.google.com by Shark92...@gmail.com on 13 Nov 2010 at 7:53

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 18 Nov 2010 at 1:44

GoogleCodeExporter commented 9 years ago
I'm not sure that eating these exceptions is a good idea.  Also, I think this 
could be a security risk since you could potentially be exposing database 
structure information to the end users.

If you wanted to do this, you could just inherit the datacontext and override 
the SubmitChanges method.

Does that help?

Original comment by e...@ericjsmith.com on 29 Nov 2010 at 5:01