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...
May 16, 2008
I think you'll be happy with C as it is an awesome language. Regarding your questions...
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?
The initialize method in the iControl assembly does in fact trap exceptions and returns a true/false from the method to indicate whether the connection was successfully initialized. This includes making a call to the System.SystemInfo.get_version() method. Originally this method did have throw the connection exceptions but from user requests, I changed this to return a success value. I can't remember exactly the reason they wanted it this way but I seem to remember it having to do with using the assembly from a scripting environment that didn't handle exceptions well and just wanted to know a true/false if it succeeded. I guess I could throw a configuration flag in there to return the exception if one is caught but it's not that way right now.
By the way, the source for the iControl assembly is available if you want to play around with it for yourself...
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" });
Now, that is different that the initialize method in that it is passing right down to the lower level proxy calls. The NetorkingVLAN member to m_interfaces is actually a property accessor returning the instance of the internal iControl.NetworkingVLAN proxy class. Since you are calling this directly, there is no catch around it inside the assembly so you'll get the exceptions passed back to your calling routine.
I'm very surprised that you say that the catch triggered but the contents of the ex Exception object is empty. Are you sure about that? I've never seen a .Net app behave that way and didn't think it was possible. I'd stop it in the debugger and look at the contents of the ex variable and double check. you can also do a print out of ex.Message.ToString() to get the raw exception message.
Hopefully this helps and if not, then please feel free to post again and let us know.
-Joe
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