Properly Handling Exception Handling


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Good morning,

I am working through some intricate code and I want to make sure I am made aware of any errors that may pop up at run-time.  How I have done this in the past is to create a class that I throw exceptions at and from there send emails or alerts to let me know what is going on.  As I understand it there is some exception handling that is already going on within the framework via an error provider.  How do I take advantage of that and still provide a streamlined way of handling my exceptions?  Also, is this a proper approach to using transactions within my code?

Here is an example of my code that I am trying to work this through:

private void cmdTransfers_Click(object sender, EventArgs e)
{
   
try
   
{
       
// Wrap this entire process in a transaction
       
BusinessLayer.TransactionBegin("MyDataSourceName", IsolationLevel.ReadCommitted);

       
// Retrieve the next [snip] . . . lots of stuff happening here . . .

      
MyLastProcedureToRun(myParm);

        BusinessLayer.TransactionCommit("MyDataSourceName");
    }
   
catch (Exception ex)
    {
       
// place cool SF exception handling here, if any

       
// this is my current way of doing it
       
SPXExceptionHandler.ReportException(ex);  // exceptions are logged, emailed, etc.
        BusinessLayer.TransactionRollback("Dynamics");
    }
}

Thanks!
Bill


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Bill Cunnien - 16 Years Ago
Greg McGuffey - 16 Years Ago
             Well said, Greg ;)
Trent L. Taylor - 16 Years Ago
Bill Cunnien - 16 Years Ago
Greg McGuffey - 16 Years Ago
Bill Cunnien - 16 Years Ago
                         #1 is solved by properly referencing the namespace. That happens way...
Bill Cunnien - 16 Years Ago
                             I'd open the form as a dialog (ShowDialog method), then access...
Greg McGuffey - 16 Years Ago
                                 Yup...I think we met the same conclusion at about the same time. Here...
Bill Cunnien - 16 Years Ago
                                     Cool!

One thing to note is that I used the using statement....
Greg McGuffey - 16 Years Ago
                                         Oh, how did you send the email? I've been thinking about doing this...
Greg McGuffey - 16 Years Ago
                                             .NET actually has some good SMTP classes for sending emails. Here is a...
Trent L. Taylor - 16 Years Ago
                                                 Thanks Trent. I've heard that this can fail because ISPs block mail...
Greg McGuffey - 16 Years Ago
                                                     [quote]Is this something you've heard of? [/quote] Thus the...
Trent L. Taylor - 16 Years Ago
                                                         Very cool! Thanks!
Greg McGuffey - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search