Forum Discussion
jcook_105986
Nimbostratus
May 16, 2008how do i use the Exception method?
im new with C.
MY system environment is as follows...
OS: XP
system: intel core2duo
compiler: visual studio 2005
please review the code below.
///////////////////////////////////////////////////////////////////////
public iControl.Interfaces m_interfaces =
new iControl.Interfaces();
try
{
m_interfaces.initialize(tb_hostname.Text,
tb_username.Text, tb_password.Text);
}
catch (Exception ex)
{
iControlProgram.ExceptionInfo exi = new iControlProgram.ExceptionInfo(ex);
if (exi.IsiControlException)
{
string msg = "";
msg = msg + "\nException: " + exi.Exception;
msg = msg + "\nLocation : " + exi.Location;
msg = msg + "\nPrimary Error : " + exi.PrimaryErrorCode + "(" +
exi.PrimaryErrorCodeHex + ")";
msg = msg + "\nSeconary Error : " + exi.SecondaryErrorCode;
msg = msg + "\nDescription : " + exi.ErrorString;
MessageBox.Show(msg);
}
}
///////////////////////////////////////////////////////////////////////
Its not a big deal, really.
All im trying to do is, just login and if i fail,
then catch an exception and analyze the reason why.
For this, I copied the whole codes directly from the following link
( http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=119 )
Currently my BIG-IP F5 server is now broken.
Until the server is fixed, mean while I want to practice on
working with exceptions methods.
In above code, when login procedure fails the code does not
go into the catch region, but rather skip the region,
and exit the function.
Qurestion 1)
How come the iControl's initialize function does not throw any
exception when it fails? Do I need to throw my own exception handle,
or is there any other way to manually throw an iControl exception?
Question 2)
In the above code example, when I replace the initialize function
with the following code, the program actually falls into the catch region.
m_interfaces.NetworkingVLAN.get_vlan_id(new string[] { "foobar" });
However, the (Exception ex)handle is empty so it does not return
any error message. Does the iControl handle must be initialized
before being able to throw any exception? or...am I doing something
wrong here?
- I think you'll be happy with C as it is an awesome language. Regarding your questions...
Qurestion 1)
Question 2)
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects