Exceptions in multi-tier model
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdebug' list.


Mikhail Goncharov
-- Moved from [aspngfreeforall] to [aspngdebug] by Sheik Yerbouti <Click here to reveal e-mail address> --

I am new to .Net and now I am trying to get used to the new way
of exceptions handling.

I am writing my first site based on 3 tier architecture
(example):

- Component handling all database operations (SQL Server) (db.dll)
(will be shared in future)
- Business layer calling database layer functions applicable to
that particular site (bus.dll)
- web page itself (test.aspx)

I am having trouble understand the following:

1. When webpage (test.aspx) calls the function in (bus.dll) and
(bus.dll) calls the sub in (db.dll), on which level do I need to check
exceptions.

2. If I check exceptions on lower level in (db.dll) like this

...
Catch e as Exception
Throw e

How do I transfer this exception to the upper page level and show the message
for the user ?

May be somebody have good example of the exceptions handling in multi-tier model

Thanks

Mikhail

Reply to this message...
 
    
Ashwin Parthasarathy
Hi Mikhail,
A few of my views on this question. Ideally you should figure out the points at which you expect errors/exceptions. For example, if the exception is going to be of a foreign key violation etc, your db component should trap it and you should raise an exception(so that your business layer understands) using the throw statement. If the error happens in the (business)logic being applied, then your business component should handle and throw an exception to your UI layer.
Finally it boils down to the following points:
Exceptions should be trapped at the earliest possible stage
All exceptions must be bubbled back to the UI layer so that the user is aware of what exactly went wrong.
Hope this helps.
Regards,
Ashwin

----- Original Message -----
From: Mikhail Goncharov
Sent: Saturday, July 27, 2002 12:46 AM
To: aspngdebug
Subject: [aspngdebug] Exceptions in multi-tier model

-- Moved from [aspngfreeforall] to [aspngdebug] by Sheik Yerbouti <Click here to reveal e-mail address> --

I am new to .Net and now I am trying to get used to the new way
of exceptions handling.

I am writing my first site based on 3 tier architecture
(example):

- Component handling all database operations (SQL Server) (db.dll)
(will be shared in future)
- Business layer calling database layer functions applicable to
that particular site (bus.dll)
- web page itself (test.aspx)

I am having trouble understand the following:

1. When webpage (test.aspx) calls the function in (bus.dll) and
(bus.dll) calls the sub in (db.dll), on which level do I need to check
exceptions.

2. If I check exceptions on lower level in (db.dll) like this

...
Catch e as Exception
Throw e

How do I transfer this exception to the upper page level and show the message
for the user ?

May be somebody have good example of the exceptions handling in multi-tier model

Thanks

Mikhail
| [aspngdebug] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdebug.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH ArchivesGet more from the Web. FREE MSN Explorer download : http://explorer.msn.com
Reply to this message...
 
    
Jai
If i am not wrong in .net the exception get transfered auto. to upper level
if not handled at lower level.
if db.dll does not handle exception it will transfer control to bus.dll, if
not exception handling is found there it
transfer control to test.aspx and when not found here too then it shows an
error. else i think if you trap the exception at test.aspx page it should
work.

-do any one has a different view?

-jigs

----- Original Message -----
From: "Mikhail Goncharov" <Click here to reveal e-mail address>
To: "aspngdebug" <Click here to reveal e-mail address>
Sent: Friday, July 26, 2002 10:39 PM
Subject: [aspngdebug] Exceptions in multi-tier model

> -- Moved from [aspngfreeforall] to [aspngdebug] by Sheik Yerbouti
<Click here to reveal e-mail address> --
[Original message clipped]

Reply to this message...
 
    
Mikhail Goncharov
Jai thanks for the comment,

The only problem I think will
be to understand what exactly went wrong, which layer failed, correct ?

Do you handle general exceptions only in your code or
trying to cover some specific exceptions ?

Mikhail

----- Original Message -----
From: "Jai" <Click here to reveal e-mail address>
To: "aspngdebug" <Click here to reveal e-mail address>
Sent: Monday, July 29, 2002 2:46 AM
Subject: [aspngdebug] Re: Exceptions in multi-tier model

> If i am not wrong in .net the exception get transfered auto. to upper
level
[Original message clipped]

Reply to this message...
 
    
Mikhail Goncharov
Ashwin, thanks

It actually confirms the theory I had before.

How are you handling exceptions ?

- Are you handling only general exceptions or ArgumentExceptions, InvalidOperation and any others ?
- if the exception is going to be of a foreign key violation etc, the user should not be aware about it,
this will be useful for the programmer only at the debug stage, correct ?

Mikhail

----- Original Message -----
From: Ashwin Parthasarathy
To: aspngdebug
Sent: Sunday, July 28, 2002 11:14 PM
Subject: [aspngdebug] Re: Exceptions in multi-tier model

Hi Mikhail,
A few of my views on this question. Ideally you should figure out the points at which you expect errors/exceptions. For example, if the exception is going to be of a foreign key violation etc, your db component should trap it and you should raise an exception(so that your business layer understands) using the throw statement. If the error happens in the (business)logic being applied, then your business component should handle and throw an exception to your UI layer.
Finally it boils down to the following points:
a.. Exceptions should be trapped at the earliest possible stage
b.. All exceptions must be bubbled back to the UI layer so that the user is aware of what exactly went wrong.
Hope this helps.

Regards,

Ashwin

----- Original Message -----
From: Mikhail Goncharov
Sent: Saturday, July 27, 2002 12:46 AM
To: aspngdebug
Subject: [aspngdebug] Exceptions in multi-tier model

-- Moved from [aspngfreeforall] to [aspngdebug] by Sheik Yerbouti <Click here to reveal e-mail address> --

I am new to .Net and now I am trying to get used to the new way
of exceptions handling.

I am writing my first site based on 3 tier architecture
(example):

- Component handling all database operations (SQL Server) (db.dll)
(will be shared in future)
- Business layer calling database layer functions applicable to
that particular site (bus.dll)
- web page itself (test.aspx)

I am having trouble understand the following:

1. When webpage (test.aspx) calls the function in (bus.dll) and
(bus.dll) calls the sub in (db.dll), on which level do I need to check
exceptions.

2. If I check exceptions on lower level in (db.dll) like this

...
Catch e as Exception
Throw e

How do I transfer this exception to the upper page level and show the message
for the user ?

May be somebody have good example of the exceptions handling in multi-tier model

Thanks

Mikhail
| [aspngdebug] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdebug.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngdebug] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngdebug.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives

------------------------------------------------------------------------------
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
Reply to this message...
 
    
Michael Lang
I think you will find the following extremely helpful:-

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp

-----Original Message-----
From: Mikhail Goncharov [mailto:Click here to reveal e-mail address]
Sent: Tuesday, 30 July 2002 12:30 AM
To: aspngdebug
Subject: [aspngdebug] Re: Exceptions in multi-tier model

Ashwin, thanks

It actually confirms the theory I had before.

How are you handling exceptions ?

- Are you handling only general exceptions or ArgumentExceptions, InvalidOperation and any others ?
- if the exception is going to be of a foreign key violation etc, the user should not be aware about it,
this will be useful for the programmer only at the debug stage, correct ?

Mikhail

----- Original Message -----
From: Ashwin <mailto:Click here to reveal e-mail address> Parthasarathy
To: aspngdebug <mailto:Click here to reveal e-mail address>
Sent: Sunday, July 28, 2002 11:14 PM
Subject: [aspngdebug] Re: Exceptions in multi-tier model

Hi Mikhail,
A few of my views on this question. Ideally you should figure out the points at which you expect errors/exceptions. For example, if the exception is going to be of a foreign key violation etc, your db component should trap it and you should raise an exception(so that your business layer understands) using the throw statement. If the error happens in the (business)logic being applied, then your business component should handle and throw an exception to your UI layer.
Finally it boils down to the following points:

*    Exceptions should be trapped at the earliest possible stage

*    All exceptions must be bubbled back to the UI layer so that the user is aware of what exactly went wrong.

Hope this helps.

Regards,

Ashwin

----- Original Message -----
From: Mikhail Goncharov
Sent: Saturday, July 27, 2002 12:46 AM
To: aspngdebug
Subject: [aspngdebug] Exceptions in multi-tier model

-- Moved from [aspngfreeforall] to [aspngdebug] by Sheik Yerbouti <Click here to reveal e-mail address> --

I am new to .Net and now I am trying to get used to the new way
of exceptions handling.

I am writing my first site based on 3 tier architecture
(example):

- Component handling all database operations (SQL Server) (db.dll)
(will be shared in future)
- Business layer calling database layer functions applicable to
that particular site (bus.dll)
- web page itself (test.aspx)

I am having trouble understand the following:

1. When webpage (test.aspx) calls the function in (bus.dll) and
(bus.dll) calls the sub in (db.dll), on which level do I need to check
exceptions.

2. If I check exceptions on lower level in (db.dll) like this

...
Catch e as Exception
Throw e

How do I transfer this exception to the upper page level and show the message
for the user ?

May be somebody have good example of the exceptions handling in multi-tier model

Thanks

Mikhail
| [aspngdebug] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdebug.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngdebug] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngdebug.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives

_____

Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com

| [aspngdebug] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngdebug.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com