Wednesday

base page asp.net error handling

basepage class:
 
public delegate void UnSafeProcedure();
public class BasePage : System.Web.UI.Page
{
public CAssertions assert= new CAssertions(); // my own assertor, produce AssertionException
public void RunSafe(UnSafeProcedure s)
{
try
{
s();
}
catch (Exception e1)
{
if (e1.GetType().FullName == "AssertionException")
{

ShowMessage(e1.Message);

}
else
{
ShowMessage("Unhandled Exception");
Debug.Write(e1.ToString());
}
}

}
// will be overwrited on actual page:
public virtual void ShowMessage(string s) { Debug.Write(s); }
}



This is how actual page would look like:
  
public partial class NewEft : BasePage {
protected void SubmitButtonClick(object sender, EventArgs e) {
RunSafe(Submit);
}

private void Submit() {

AUtyl butyl = new AUtyl();
assert.IsTrue(butyl.CheckRoutingNumberByRouting(txtRoutingNumber.Text), "Routing Number is invalid");
}

public override void ShowMessage (string s ) { lblMessage.Text = s; }
}




more...

2 comments:

Diva said...

hi..
can u help me to select the content of ms.word from ruby??
i have a proble with it..

Anonymous said...

it also can be run as anonymous function without creation "Unsafe" function like this :

RunSafe(delegate() {
/// unsafee code here
});

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...