StrataFrame Exceptions vs .NET Exceptions

Author Message
 Posted 3/1/2013 4:21:39 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 12/8/2014 4:29:38 AM
Posts: 80, Visits: 239

I'm a begginer StrataFrame developer and am interested in what benefit I would get out of using the StrataFrame Exception class over just the base .NET exception class.

I have a console app that has a very basic try/catch error handler where an exception is entered into the Windows EventLog like this:

l_ovCalLog.WriteEntry(l_oException.ToString(), EventLogEntryType.Error)

Which is fine for what I'm using it for, but I'm interested in what StrataFrame tools/classes I can use for my benefit outside of a normal Winforms app.

Post #31891
Add to Twitter Add to Facebook
 Posted 3/1/2013 4:46:36 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 5/16/2018 3:20:37 AM
Posts: 2,982, Visits: 2,482
You can throw any exception you want.  According to Microsoft's guidelines, they used to say that you should base any exceptions you create off of ApplicationException.  It's the base class for almost every exception in the .NET Framework.  But they have now changed their mind:

About halfway down this article:
For most applications, derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value.
You can throw StrataFrameExceptions if you want.  We don't add any extra features to the StrataFrameException class.  We created it and the BusinessLayerException and DataLayerException classes in order to wrap common exceptions and give more information that a developer can use to solve the problem.  Most of it is configuration-related stuff.  For instance, if you try to run a query without first adding a DataSource to the DataBasics.DataSources collection, we don't just throw a KeyNotFoundException from .NET, we wrap it and say "hey, you need to add a data source before you try this."

Now, the StrataFrameException class doesn't add anything extra, but we have some exception helpers that are useful.  We have the MicroFour.StrataFrame.Tools.Exceptions class.  The most useful method on it is the CreateExceptionDetails() method which returns a string that lists all of the inner exceptions and a combined stack trace of all of the inner exceptions.  It also includes extra information on common exceptions like TypeLoadExceptions and such that have extra details in there internal IList stuff.

We also have the MicroFour.StrataFrame.Application.ApplicationErrorDialog which shows an exception using the CreateExceptionDetails() method mentioned above in a nice, red box.

The default project template also adds handlers to AppDomain.Current.UnhandledException to trap exceptions that are, you guessed it, unhandled.

Hope that helps.
Post #31894
Add to Twitter Add to Facebook

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.