code: def handleError(exception, debugFlag=False, abortFlag=True):
      
      if isinstance(exception, CmdError) or not debugFlag:
          error(str(exception))
      else:
          import traceback
          traceback.print_exc()
          error(str(exception))   # or log complete traceback as well?
      if abortFlag:
          sys.exit(1)
docs: Error handling utility. Print more or less error information
         depending on debug flag. Unless abort is set False, exits with
         error code 1.