Architecture :: Best Practice For Handling Exception?

Jun 3, 2010

I devide my website on 3 layers :

DAL(Data Access) - simple extract data from DB using LINQ
BLL(Business Logic) -

cache data and in try/catch block call function from DAL and throw it to UI :
try
{
}
catch (Exception ex)
{
//Log error
throw ex
}

UI (User Interface) - simple working without handling any exception,

So if error occured in BLL i will be redirected to Error.aspx page with message that something wrong.

how and where handle exceptions, or may be exists common patter where handle and how to inform user about errors ? Can anybody share bes practice.

View 1 Replies


Similar Messages:

Architecture :: Exception Handling In MVP?

May 28, 2010

I'm wondering what's the preferred way to manage exceptions in an MVP implemented with a Passive View.

There's a discussion in my company about putting try/catch blocks in the presenter or only in the view.

In my opinion the logical top level caller is the presenter (even if the actual one is the view).

Moreover I can test the presenter and not the view. This is the reason why I prefer to define a method in the view interface:

[Code]....

View 2 Replies

Architecture :: Design A Good Exception Handling?

Jun 4, 2010

I need to design a good exception handling. That can include logging and user friendly error page etc I read more articles and got some ideas. I am not using Enterprise Library now.

View 4 Replies

Architecture :: Exception Handling In Multi-tiered Applications?

Apr 27, 2010

Even though I'm trying to implement exception handling in a multi-tiered Windows application, catching and throwing exceptions should be the same for Windows and Web (sans global.asax and web.config custom errors).

I have a webform with a texbox that displays exceptions. So my webform invokes a method in BusinessTier class which then invokes a method in DataTier class. How can I throw my DataTier method exception so it reaches my webform?

View 2 Replies

Architecture :: Dynamic Exception Handling In Saas Application?

Dec 29, 2010

Dynamic Exception handling in Saas application

View 3 Replies

Architecture :: Exception Handling Between Data Access Layer And Code Behind?

Jul 20, 2010

If an error happens in the DA_layer, how do I pass it do the code_bedhing to show the user?

[Code]....

View 3 Replies

C# - Exception Handling - Implement Custom Exception Classes?

Jul 2, 2010

i have this application structure:

1. Presentation Layer which calls

2. Business Logic Layer which in turn calls

3. Data Access Layer to do the dealing with the database.

Now i have a Contacts page from where i can add a new contact to the database.So to add a New Contact i fill in all the required details and then call a Add Method (residing in the BLL) from the page, which in turn call a Add Method residing in the DAL.this method in the DAL returns the Current Identity of the record which is then return back to the BLL method and finally delivered on the page.this is fine. but what if a get an exception how do i handle it properly because the method in DAL has a return type of int and i dont want to throw another error!! coz other wise i will have to write try catch in almost all the methods.

//something like this
public int AddMethod(ContactClass contactObj)
{
int result = 0;[code]...

rather i want to show the user a user-friendly message which they can easily understand and in the mean while i will send a mail to myself documenting the Error that just occurred.how can i implement my custom exception classes.

View 2 Replies

WYSIWYG Best Practice For Handling Fonts Faces

Aug 23, 2010

I have a WYSIWYG textarea (CKeditor) in my CMS.Most of the users write the article first in a word document and then paste it in the textarea.

Sometimes they paste as plain text, but sometimes not. And sometimes the articles final result is a mess because of the HTML that Word generates.

I have problems specially with the fonts, people change font face in Word and when they paste text in the textarea, the font face used in Word remains (seems that Word uses the <font> tag.

View 3 Replies

Web Forms :: Best Practice For Handling Multiple Requests At The Same Time?

Jul 8, 2010

we have this web service that sends JSON code to an iPhone application.

Each time the app makes a request, the web serice accesses the database, grabs corresponding xml data, transforms it to JSON code and then sends it back to the app.

the xml data gets updated approximately every minute, you can assimiliate this process with a sport app of which you can watch live game commentaries.

Now the iPhone app is going to implement a refresh button which a user can proactivly hit it against the service to fetch the latest data.

So we need to implement something that is capable of handling multiple requests that could occur at the same time or in a very short period of time.

View 3 Replies

Architecture :: How To Log Dal Exception And Showing Alert To User / Exception Occurs

Aug 3, 2010

I am working on a 3-tier asp.net application. Currently I'm stuck up in a situation where I need to handle a specific type of exception (User Defined) in DAL and Show alert to the user if that exception occurs in DAL.

I tried following things:

1) I raised that exception from the DAL and catch it in BLL and throw a new BLL exception to for that DAL exception and finally catch it in the UI layer to show the alert to the user. I've successfully implement this in my project. But there are some issues in this approach. First of all I feel this is not right way to do this as it may lead to performance related issues. Secondly, the application contains more than 500 pages and classes. so I need to attach additional catch block in every method to catch the BLL exception. which is the last option i'd like to take.

2) in second approach I logged the the DAL exception into a text file. but problem in this approach is that how could the UI layer know that exception has occurred and show the alert to the user. Is there any event in asp.net where i could handle all this activities?

my question is what is the best approach to handle this type of situation? Will Exception handling block help me in this?

I've tried reading many articles on this but i couldn't get an answer for my question? I might not be using right keywords for my search.

View 4 Replies

C# - Best Practice To Handle Exception In The Async Call?

Nov 11, 2010

For example, I am using wenclient.DownloadfileAsync to download a file asynchronously.

In the DownloadFileCompleted event handler, I can check if I have any exception or not by using AsyncCompletedEventArgs.Error property.

If I re-throw this exception, however my executable is stopping running immediately.

I am wondering how to handle this kind of exeception? How to pass this exception back to the
calling thread?

View 1 Replies

Architecture :: Finding Best Practice For Designing Classes - OOP

Aug 10, 2010

I am searching for what are the standard best practice (for OOP) used to design classes for develop asp.net application? I am aware of most of the OOP concepts but confused with how to map object/classes.

Let's take example of Adventure works - 2005 database provided by Microsoft; it has five schemas Sales, Purchase, Person, Production, HR and DBO.

Should we consider Schemas as Namespace in Classes?

Now, Person schema has 5 tables, should we design classes based on tables?

i.e. Person schema has Address, AddressType, Contact, ContactType, CountryRegion & StateProvince tables. What are the classes we can consider?

What are the basic criteria to decide objects? What to do and how to design classes for tables like Purchase order detail, Product cost history, Product inventory, Product Category etc.

View 3 Replies

Architecture :: Exception Layer In N-tier Architecture?

May 13, 2010

I'm developing a n-tier architecture... I'm confused with handling exception in the layers... Is it a good practise to add a Exception Layer to the architecture.

View 3 Replies

ADO.NET :: DLL Exception Handling?

Mar 25, 2011

I created a simple data access layer in the dll and reference it in my web app. How can I point the error to the user that his code in this line has an exception. currently, when i input a nonexisting table it will popup an error "invalid object name table_name" and points the my code throw exception inside my dll. I want it to point out to the user code that uses my function that creates an error.

Line 92: Dim ds As DataSet = DAL.Dal.ExecuteDataset("SELECT * FROM table_nam", "DBConnectionString")

Line 93: GridView1.DataSource = ds.Tables(0)

View 4 Replies

C# - Exception Handling Internal Bug?

Mar 18, 2011

Code:

public static void Test()
{
try
{
OpenConnectionToDatabase(); //Opens a connection to Oracle DB
} catch(Exception e)
{
e.Data.Add("Query:", command.CommandText);
throw e;
}
}

When this code is executed when the Database server is being shutdown and the communication is disrupted, .NET throws the following error: Item has already been added. Key in dictionary: 'Query:' Key being added: 'Query:' at System.Collections.ListDictionaryInternal.Add(Object key, Object value) How can this be?

View 2 Replies

MVC :: Exception Handling With RenderAction?

Feb 24, 2010

We are using renderaction provided by MVC futures. We've noticed that HttpExceptions in child action methods are not propagated to the parent action. Even though a fragment has failed, we still see the parent request resulting in a 200, and this throws our error handling for a toss.

View 4 Replies

MVC :: Can't Get Exception Handling To Work?

Aug 3, 2010

I have a weird situation here. Using VS2010 and the MVC2 application template, I'm trying to set up error handling, but it refuses to work... Even with a simple controller throwing an exception in the index:

[Code]....

And <customErrors mode ="On"></customErrors> in the web.config file, MVC breaks into the code and tells me that "Exception was unhandled by user code". The default Error.aspx (static text only) is located in /Views/Shared, and I've even removed the login partial view from the master page.

View 2 Replies

Exception Handling While Reading RSS Or XML?

Nov 12, 2010

I have a code which reads from a database and loads all feeds in it. Occassionaly I will get errors when the feeds are not responding. The error is happening on this line of code:

[Code]....

How do I add in a code that if the read above fails, ignore and proceed to next data row in the SQLDataReader ?

View 1 Replies

How To Throw And Catch Exception Handling

Oct 12, 2010

iam inserting record in three tables in a database, iam using begin trans , commit transaction and rollback,

i want to use throw method, if any value insert wrong, pls correct me, i want to throw the error and

its go to rollback

running = false;
int updaterec = DBmgr.ExecuteNonQuery(CommandType.Text, "update ASArrivedcontainer set billgen ='Y' where billgen ='y' and acontinerid in ("+SelValues+")");
if (updaterec > 0)
{
running = true;
DataSet BillContainerDetails = BillingDetails();
byte[] ContainerDetails = GenerateBill(DBmgr, sContainerIds, rcno,isGeneralRCNo, FetchContainerDetails, ModifyId,ref BillContainerDetails);
DBmgr.CreateParameters(6);
//string otherchargesId = obj.retriveSingleRecord("select top(1) ModifyId from ASOtherCharges");
DBmgr.AddParameters(0, "@InvoiceNo", "1","IN");
DBmgr.AddParameters(1, "@BillDate", DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss tt"), "IN");
DBmgr.AddParameters(2, "@CustomerId", "1", "IN");
DBmgr.AddParameters(3, "@TotalAmount", "10000", "IN");
DBmgr.AddParameters(4, "@OtherChargesId", ModifyId, "IN");
DBmgr.AddParameters(5, "@ContainerDetails", ContainerDetails, "IN");
String BillNo = DBmgr.ExecuteScalar (CommandType.Text, "Insert into BillMaster(InvoiveNo,BillDate,CustomerId,TotalAmount,OtherChargesId,ContainerDetails) values (@InvoiceNo,@BillDate,@CustomerId,@TotalAmount,@OtherChargesId,@ContainerDetails)
Select @@Identity ").ToString();
if (!String.IsNullOrEmpty(BillNo))
{
running = true;
DBmgr.CreateParameters(4);
for (int i = 0; i < BillContainerDetails.Tables[0].Rows.Count; i++)
{
BillContainerDetails.Tables[0].Rows[i]["BillNo"] = BillNo;
DBmgr.AddParameters(0, "@Billno", BillContainerDetails.Tables[0].Rows[i].ItemArray[1].ToString(), "IN");
DBmgr.AddParameters(1, "@rcno", BillContainerDetails.Tables[0].Rows[i].ItemArray[2].ToString(), "IN");
DBmgr.AddParameters(2, "@acontinerid", BillContainerDetails.Tables[0].Rows[i].ItemArray[3].ToString(), "IN");
DBmgr.AddParameters(3, "@bflag", BillContainerDetails.Tables[0].Rows[i].ItemArray[4].ToString(), "IN");
//string value = BillContainerDetails.Tables[0].Rows[i].ItemArray[0].ToString(); ;
// string strsql = "insert into billcontinerdetail(billno,rcno,acontinerid,bflag) values(@billno,@rcno,@acontinerid,@bflag)";
String count = DBmgr.ExecuteScalar(CommandType.Text, "insert into billcontinerdetail(billno,rcno,acontinerid,bflag) values(@billno,@rcno,@acontinerid,@bflag)Select @@Identity").ToString();
if (count > 1)
{
running = true;
}
else
{
}
//running = true ;
//break;
}
DBmgr.CreateParameters(6);
for (int j = 0; j < BillContainerDetails.Tables[1].Rows.Count; j++)
{
DBmgr.AddParameters(0, "@billcontkey", BillContainerDetails.Tables[1].Rows[j].ItemArray[1].ToString(), "IN");
DBmgr.AddParameters(1, "@ratetypcode", BillContainerDetails.Tables[1].Rows[j].ItemArray[2].ToString(), "IN");
DBmgr.AddParameters(2, "@days", BillContainerDetails.Tables[1].Rows[j].ItemArray[3].ToString(), "IN");
DBmgr.AddParameters(3, "@amount", BillContainerDetails.Tables[1].Rows[j].ItemArray[4].ToString(), "IN");
DBmgr.AddParameters(4, "@level", BillContainerDetails.Tables[1].Rows[j].ItemArray[5].ToString(), "IN");
DBmgr.AddParameters(5, "@sflag", BillContainerDetails.Tables[1].Rows[j].ItemArray[6].ToString(), "IN");
// string strsql = "insert into billratedetail(billcontkey,ratetypcode,days,amount,level,sflag)values(@billcontkey,@ratetypcode,@days,@amount,@level,@sflag)";
String count = DBmgr.ExecuteScalar(CommandType.Text, "insert into billratedetail(billcontkey,ratetypcode,days,amount,level,sflag)values(@billcontkey,@ratetypcode,@days,@amount,@level,@sflag)Select @@identity ").ToString()
;

View 2 Replies

Exception Handling In Server.transfer

Feb 26, 2011

A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code

After banging my head because i could find where the exception came for and global.asax didn't get hit i found that it's from server.transfer and is a known bug. The alternative i read about is server.execute.However if i do this then the next page fires multiple javascript exceptions and a gridview i have is breaking of and the rows appear half at the left page corner and half inside the gridview!!

For now i just put a try catch on the server.transfer although the exception will not affect the application even if i don't use try catch. I also see that the exception is happening again even if i put try catch but with different dll: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in App_Web_benglxq1.dll An exception of type 'System.Threading.ThreadAbortException' occurred in App_Web_benglxq1.dll but was not handled in user code Now what on earth is benglxq1.dll i don't know. What i know is that i'm leaving an exception to run and i don't like that. This is the js error when i use server.transfer btw: Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Sys._Application' cannot be converted to type 'Sys._Application'.

View 8 Replies

Exception Handling In Background Threads?

Jun 15, 2010

When I do ThreadPool.QueueUserWorkItem, I don't want unhandled exceptions to kill my entire process. So I do something like:

ThreadPool.QueueUserWorkItem(delegate() {
try { FunctionIActuallyWantToCall(); }
catch { HandleException(); }
});

Is this the recommended pattern? It seems like there should be a simpler way to do this. It's in an asp.net-mvc app, if that's relevant.

View 1 Replies

C# - .NET Exception Handling Lookup From A Table?

Mar 25, 2011

My manager designed a table exactly like this

[Exception]
PK | ExceptionId
ExceptionCode varchar(100)
ExceptionDesc varchar(255)
ExceptionMSG varchar(255)

I'm using ASP.NET Webforms and using stored procedures/ADO.NET for DataAccess. Now he does not want me to hard code validation in stored procedures nor in the code behind, but to catch the constraint exception message and look up the same error message in the database and look for the message that we want to show. I wonder if his design will work or should I explain to him that something is wrong here.

View 2 Replies

Configuration :: Exception Handling For Email?

Oct 7, 2010

I am writing a exception handling for errors on my application in the "

Sub Application_Error(ByVal
sender As
Object,

[code]...

View 10 Replies

AJAX :: Exception Handling - How To Solve Response.End

Dec 15, 2010

After many years reading this forum... I didn't found the solution to my actual problem... When I tought... this could be a big problem... I have a web app wich doesn't have try catch blocks in every method... so I need to implement a generic solution to handle exceptions and the most important... show some BO exceptions to user inside a MessageUserControl (ASCX) wich uses AJAX. this is the big problem, I tried many solutions, application_error, a specific log module, page_error... and with all I got to the same problem...

The UpdatePanel, when it got an unhandled exception, it fires the events (application_error, page_error) or even the httpmodule, but I think it call an Response.End, wich stops any action in the page... and this is just I don't want to do... I need to display the message to the client. this is the call to show the message...

[Code]....

My page wich gots an unhandled exception are inside an UpdatePanel, if I remove it, the message shows UP! I'm working on this for 5 long days.

View 4 Replies

Browser Not Handling Exception From AJAX Panel - C#

May 27, 2010

i am having trouble catching errors in an AJAX panel. Even when i throw an exception in the c# code behind the front end completely ignores it. Here is the code i have setup, can anyone see why? I ideally want to show a js alert window on error.

protected void btnX_Click(object sender, EventArgs e)
{
throw new ApplicationException("test");
}
protected void ScriptManager_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
{
ScriptManager.AsyncPostBackErrorMessage = e.Exception.Message;
}

Markup:

<script type="text/javascript" language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, e)
{
window.alert(e.get_error().name);
}
</script>

<asp:ScriptManager ID="ScriptManager" runat="server" AllowCustomErrorsRedirect="true" OnAsyncPostBackError="ScriptManager_AsyncPostBackError" />

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved