Using statements swallowing exceptions
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
ARGGGGGHH
I have a database class instantiated with a Using statement, then a
reader also instantiated with a using statement.
If the command I use to populate the reader throws an exception, then
that exception gets "swallowed" and never populates back up the callstack.
I added a threadexception handler and this catches the exception at the
top level except before my main form fully loads which does the data
loading in the load event.
Flow of events
MAIN >> Add threadexception handler that shows messagebox with exception
message >> run new form1 >> form1 load >> load data >> exception thrown
>> no messagebox.
After form is loaded and displayed
Combo box selectionchanged >> loads data same as form1 load >> exception
thrown and caught and messagebox displayed.
Any Ideas?
The actual code that invokes the command that throws the exception is
using(DB db = DatabaseManager.CreateDatabase())
{
... setup command
using(IDataReader Reader = db.GetReader(Command)) //db.GetReader throws
exception because of a syntax error
{
}
}
Cheers
JB
.
Relevant Pages
- Re: C# / ASP.Net System Design Confusion
... That would be log the exception where it occurs and populating the exception back to the top. ... populate the excprtion back to the top/UI and and abort. ... A parent object can have multiple child objects, and the parent object can have more than one set of child objects related to a parent object, a parent object with its collection of child objects. ... You can have more than one Select statement in the SP, you can use a resultset MoveNext to move to the next resultset, read each record in a given resultset, populate an object or objects related to the resultset, etc, etc. ... (microsoft.public.dotnet.general) - Re: Runtime Syntax Checker
... If any Tcl command sets a return code other than zero, ... script to abort, but any following scripts will execute. ... In C, you can ignore errors, execution ... The caller must then handle the exception. ... (comp.lang.tcl) - Re: SQLCE Exception
... Does this exception only occur when rows have been added? ... > A duplicate value cannnot be inserted into a unique index> ... > My command builder and update code is:> ... > uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT ... (microsoft.public.dotnet.framework.compactframework) - Re: SqlCommand.ExecuteReader returning nothing?
... it is really hard to imagine ExecuteReader returning Nothing ... wouldn't an exception have been caught by the try catch block ... Dim cn As New SqlConnection ... Dim reader As SqlDataReader = Nothing ... (microsoft.public.dotnet.framework.adonet) - Re: I/O Error
... If your users don't know how to use a command line, then you should really be getting the filenames through some sort of GUI instead of raw_input. ... If an exception occurs that will result in the end of the program, there's no point in catching it just to print a less descriptive error message and quit. ... def io: ... As far as the interface goes, you can run this from the commandline as example.py INFILE OUTFILE LOGFILE. ... (comp.lang.python) |
|