Click here to Skip to main content
Click here to Skip to main content

Custom Exception Framework: Using Enterprise Library Exception Handling Block

By , 30 Oct 2008
 
//--------------------------------------------
//  Author        : Santosh Poojari
//  Created Date  : 22/02/2008
//  Email ID      : santosh.poojari@gmail.com
//--------------------------------------------

#region References
using System;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

using Project.Practice.MVP.Domain;
using Project.Practice.MVP.Presenter;
using Project.Practice.MVP.Framework;
using Project.Practice.MVP.ExceptionHandling;
using Project.Practice.MVP.ExceptionHandling.CustomException;
#endregion

public partial class Calculation : CustomPage,ICalculationView
{
    #region Private Members
    private CalculationPresenter m_Presenter = null;
    #endregion
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            m_Presenter = new CalculationPresenter((ICalculationView)this);
            if (ViewState["USER_KEY_VALUE"] == null)
            {
                throw new ViewLayerException("Code Behind Exception");
            }
        }
        catch (Exception ex)
        {
            if (ExceptionHandleProvider.HandleException(ex, "Global Policy") == true)
            {
                throw ex;
            }
        }       
    }

    #region ICalculationView Members

    public int Numbers1
    {
        get
        {
            return Convert.ToInt32(txtNumber1.Text);
        }
    }

    public int Numbers2
    {
        get
        {
            return Convert.ToInt32(txtNumber2.Text);
        }
    }

    public string Result
    {
        set
        {
            lblResult.Text = value;
        }
    }

    #endregion
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            m_Presenter.AddNumbers();
        }
        catch (Exception ex)
        {
            if (ExceptionHandleProvider.HandleException(ex, "Global Policy") == true)
            {
                throw ex;
            }
        }      

    }

    public override string Error
    {
        set {pnlError.Visible = true;
            lblException.Text = value; ; }
    }
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

santosh poojari
Technical Lead
India India
Member
He is presently working as tech arch in one of the leading IT company.He has total 10 years of experience in C#.net. He is a B.E graduate in Computers from Bombay University.
 
Most of his experiences are in designing architect for end to end solutions. His interest areas are WCF,Spring.net,Architecture- Model View Presenter,UML,Webservice,Performance Engineering/tuning,Design patterns,Generics,Enterprise Library,Regular expressions,Silverlight and WWF.
www.santoshpoojari.blogspot.com

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 30 Oct 2008
Article Copyright 2008 by santosh poojari
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid