Forum Discussion

Twirrim_94896's avatar
Twirrim_94896
Icon for Nimbostratus rankNimbostratus
Jul 18, 2011

Exception Catching

I'm struggling a little with pycontrol and catching exceptions.

 

 

I've written a python script that parses the contents of a series of files in a directory (cvs managed), concatonates them into a iRule and applies it to the Load Balancer. I've got 80+ vhosts, all with multiple URI or similar redirects each... I shudder at the thought of handling that monolithically, and they're each so quirky and unique that templating is futile.

 

 

My idea is to produce a temporary rule_def for each vhost, push it to the load-balancer and report back to the user the exact error message if one came up, and then sys.exit. Hopefully then the deployer could fix the fault and re-try.

 

 

What I can't figure out is how to get at the Common.OperationFailed response (at least not without crashing with a full stack trace). Is it possible?

 

2 Replies

  • Twirrim: are you using try / except / finally logic with your scripts?

     

    --Matt
  • Yes, but that just allows me to do a graceful exit, what I'm trying to do is gracefully exit with just the error string. After a whole bunch of digging around I discovered needed to do "import suds" and then have "except suds.WebFault as details:", now I'm just working on cutting down details to just the error string rather than the whole message.

     

     

    Found it really strange that there are codeshare examples against virtually everything in the API Docs, but not the error stuff. I know I never make an error, ever, so error catching is probably a waste of time for me to code in .. but still ;)