Posted on November 23, 2017 5:03 pm
 |  Asked by Jon Nicholson
 |  401 views
0
0
Print Friendly, PDF & Email

What’s the best way of handling error conditions in a python configlet builder?

My script takes data from a git repository to generate the configlet, the script validates the data before generating the configuration. If it’s invalid it will need to signal an error to CVP.

What’s the best way to do this?

I’m thinking I should raise and exception, however this simple test doesn’t seem to do the right thing:-

<pre>

from cvpServices import CvpError
import errorCodes

CvpError(errorCodes.CONFIGLET_GENERATION_ERROR, ‘error an error occured’)

</pre>

Any suggestions?

0
Posted by Tyler Conrad
Answered on November 24, 2017 11:13 pm

Are you able to share how you’re integrating git? Sounds like something that would be useful. 

 

We do simple error handling by doing something like below

 

if VARIABLE == GOODVALUE:

  dotask()

else:

  print ‘Value ‘, VARIABLE, ‘is outside the accepted range’

  return

Post your Answer

You must be logged in to post an answer.