Connecting Tech Pros Worldwide Forums | Help | Site Map

Error Handling in Business Object Layer

Big Dave
Guest
 
Posts: n/a
#1: Nov 19 '05
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

*** Sent via Developersdex http://www.developersdex.com ***

Michael Baltic
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Error Handling in Business Object Layer


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


"Big Dave" wrote:
[color=blue]
> 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
>
> *** Sent via Developersdex http://www.developersdex.com ***
>[/color]
Kevin Spencer
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Error Handling in Business Object Layer


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

"Michael Baltic" <MichaelBaltic@discussions.microsoft.com> wrote in message
news:D032A8B2-23CC-4500-B047-79D766294400@microsoft.com...[color=blue]
> 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
>
>
> "Big Dave" wrote:
>[color=green]
>> 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
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
>>[/color][/color]


Michael Baltic
Guest
 
Posts: n/a
#4: Nov 19 '05

re: Error Handling in Business Object Layer


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


"Kevin Spencer" wrote:
[color=blue]
> 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
>
> "Michael Baltic" <MichaelBaltic@discussions.microsoft.com> wrote in message
> news:D032A8B2-23CC-4500-B047-79D766294400@microsoft.com...[color=green]
> > 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
> >
> >
> > "Big Dave" wrote:
> >[color=darkred]
> >> 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
> >>
> >> *** Sent via Developersdex http://www.developersdex.com ***
> >>[/color][/color]
>
>
>[/color]
Kevin Spencer
Guest
 
Posts: n/a
#5: Nov 19 '05

re: Error Handling in Business Object Layer


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

"Michael Baltic" <MichaelBaltic@discussions.microsoft.com> wrote in message
news:7FBB4D88-41E9-4722-972D-78D7233A0A29@microsoft.com...[color=blue]
> 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
>
>
> "Kevin Spencer" wrote:
>[color=green]
>> 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
>>
>> "Michael Baltic" <MichaelBaltic@discussions.microsoft.com> wrote in
>> message
>> news:D032A8B2-23CC-4500-B047-79D766294400@microsoft.com...[color=darkred]
>> > 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
>> >
>> >
>> > "Big Dave" wrote:
>> >
>> >> 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
>> >>
>> >> *** Sent via Developersdex http://www.developersdex.com ***
>> >>[/color]
>>
>>
>>[/color][/color]


Closed Thread