J
joseph
Hi,
I have managed to use the try{} catch{(Exception e)} to catch all
exceptions that is happens in the application.
My application is an Active Directory Interface and need to report all
exceptions and handle them differently so I need to find out what code
to Class to use so I can act differently.
The first catch does not work and always goes to the second catch when
I supply wrong Username and password. I am thinking maybe I am using
the wrong class. How do I know which class to use???
For example:
catch (System.UnauthorizedAccessException e1)
{
StringBuilder lsb_TempString = new StringBuilder();
lsb_TempString.AppendFormat(@"My Exception: ");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(@"BAD Username or password");
lsb_TempString.AppendFormat(e1.ToString());
throw(e1);
}
catch (System.Runtime.InteropServices.COMException e2)
{
StringBuilder lsb_TempString = new StringBuilder();
lsb_TempString.AppendFormat(@"My Exception: ");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(@"BAD Domain Address");
lsb_TempString.AppendFormat(e2.ToString());
throw(e2);
}
catch (Exception e3)
{
StringBuilder lsb_TempString = new StringBuilder();
lsb_TempString.AppendFormat(@"My Exception: ");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(@"Unknown Exception");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(e3.ToString());
throw(e3);
}
I have managed to use the try{} catch{(Exception e)} to catch all
exceptions that is happens in the application.
My application is an Active Directory Interface and need to report all
exceptions and handle them differently so I need to find out what code
to Class to use so I can act differently.
The first catch does not work and always goes to the second catch when
I supply wrong Username and password. I am thinking maybe I am using
the wrong class. How do I know which class to use???
For example:
catch (System.UnauthorizedAccessException e1)
{
StringBuilder lsb_TempString = new StringBuilder();
lsb_TempString.AppendFormat(@"My Exception: ");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(@"BAD Username or password");
lsb_TempString.AppendFormat(e1.ToString());
throw(e1);
}
catch (System.Runtime.InteropServices.COMException e2)
{
StringBuilder lsb_TempString = new StringBuilder();
lsb_TempString.AppendFormat(@"My Exception: ");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(@"BAD Domain Address");
lsb_TempString.AppendFormat(e2.ToString());
throw(e2);
}
catch (Exception e3)
{
StringBuilder lsb_TempString = new StringBuilder();
lsb_TempString.AppendFormat(@"My Exception: ");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(@"Unknown Exception");
lsb_TempString.AppendFormat("\n");
lsb_TempString.AppendFormat(e3.ToString());
throw(e3);
}