V
Vadivel Kumar
I've a problem in handling a custom exception
The following is my custom exception class:
public class AppException : public Exception
{
public AppException (string message, Exception innerException)
{ }
public override string Message
{
get {
return base.Message + "Blahblah..";
}
}
}
This is my implementation:
Using Exception_Namespace;
public MakeConnection
{
SqlConnection Connection;
try
{
Connection = new SqlConnection("bbababa");
}catch(AppException e)
{
Response.Write(e.Message.ToString());
}
}
when i execute this, it is not catching the error....it shows the
ArgumentException which is because
of the wrong connection string has been passed. I'm expecting the "blah.."
string added to the overriden
message property of AppException class.
Rather, If i use Exception instead of AppException it is working fine.
So, Why it is not working when i'm using AppException? What is wrongness i'm
doing here?
Thanks in Advance
Vadivel Kumar
The following is my custom exception class:
public class AppException : public Exception
{
public AppException (string message, Exception innerException)
{ }
public override string Message
{
get {
return base.Message + "Blahblah..";
}
}
}
This is my implementation:
Using Exception_Namespace;
public MakeConnection
{
SqlConnection Connection;
try
{
Connection = new SqlConnection("bbababa");
}catch(AppException e)
{
Response.Write(e.Message.ToString());
}
}
when i execute this, it is not catching the error....it shows the
ArgumentException which is because
of the wrong connection string has been passed. I'm expecting the "blah.."
string added to the overriden
message property of AppException class.
Rather, If i use Exception instead of AppException it is working fine.
So, Why it is not working when i'm using AppException? What is wrongness i'm
doing here?
Thanks in Advance
Vadivel Kumar