Error Handling in Business Object Layer

B

Big Dave

Does anyone have suggestions on how to best handle errors in business
objects that are part of a business layer? For example:

Public Class Person
Private _name as string
Public Property Name as string
Get
Return _name
End Get
Set(Value as string)
If Value.toString.length > 50 then


'How do I send a friendly error message back to the
presentation layer saying the value isn't correct? I know I can
validate it on the form, but I'd like to also validate in the business
objects.


Else
_name = Value
End If
End Set
End Property

End Class


Thanks in advance for any help!!!
Big Dave
 
G

Guest

In my business objects, I have a error collection class. It has a method to
pretty print the collection in html format.

I can then perform my business operation and catch all of the exceptions
without rethrowing them. Then, if my error collection has a size > 1 I know
there was an error and I print them to the page.

Or, just always put a try catch around business transactions and never put
them in your business/data layer.

There are always arguments either way..... to ignore errors in the
business/data layer and just continue processing or.... warn/throw an error
to the calling procedure when you encounter something bad!
--
Direct Email: Michael.Baltic@RemoveCharactersUpTo#NCMC.Com

Staff Consultant II
Enterprise Web Services
Cardinal Solutions Group
 
K

Kevin Spencer

What do you do if Uncle Ernie drops his chopsticks?

--

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
G

Guest

LOL! I don't even know what movie/show that referenced, but I must have
laughed for like ten minutes!!!!
--
Direct Email: Michael.Baltic@RemoveCharactersUpTo#NCMC.Com

Staff Consultant II
Enterprise Web Services
Cardinal Solutions Group
 
K

Kevin Spencer

Thanks Michael,

Actuallly, it's a fragment that Uncle Chutney culled from a local radio
commercial. Taken out of context, it can mean almost anything, and strikes
me as quite ambiguously funny as well.

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top