This project is read-only.

error handling

Feb 20, 2009 at 7:09 PM

I have looked at the example you included (CodeUse_Web) as an inspiration to construct my own class.
However I can't figure out how to handle errors. The errors are nicely added in the "Error" list in the dataAccess layer, but how to pass it to the objectDS and present them to the end-user?

For example I am getting an error in the "Save"-method, stating a SQL-error, errors are stored in "Me.Errors"
But the save-method only returns an empty can I pass and show the errors in my webpage? Could this - the errorhandling - be included in the nice example that's included (CodeUse_Web)?

Thanks for this great wizard!

Feb 20, 2009 at 8:31 PM
Hi Herman,

I'm glad you're getting some good use out of this tool.

As far as error handling goes, I would first say that it is almost always bad to show the end-user an error message; especially when it came from your data access layer. You could accidentally show information about your database structure to the world. Most of the time, you'll want to log the exception you're getting and display a dumbed-down error to the user like, "There was an error saving your data. Please try again or contact support."

While I'm sure you already know that, I just wanted to cover that base for anyone else who's reading this thread.

The general idea would be to check the .Errors property from the calling code and if its count is greater than zero, you know you have problems. As always, the error handling in the data access class is just a suggested way to handle data-layer exceptions. You might want to implement some sort of exception handling framework instead. I would highly recommend at least a cursory look at the Enterprise Patterns and Practices library for that purpose.

I'll take a look at the web example this weekend and try to update it with some better error handling examples.

Thanks for the feedback and feel free to post any further questions.