exceptions.py 957 B

1234567891011121314151617181920212223242526272829303132
  1. """
  2. Custom Fabric exception classes.
  3. Most are simply distinct Exception subclasses for purposes of message-passing
  4. (though typically still in actual error situations.)
  5. """
  6. class NetworkError(Exception):
  7. # Must allow for calling with zero args/kwargs, since pickle is apparently
  8. # stupid with exceptions and tries to call it as such when passed around in
  9. # a multiprocessing.Queue.
  10. def __init__(self, message=None, wrapped=None):
  11. self.message = message
  12. self.wrapped = wrapped
  13. def __str__(self):
  14. return self.message or ""
  15. def __repr__(self):
  16. return "%s(%s) => %r" % (
  17. self.__class__.__name__, self.message, self.wrapped
  18. )
  19. class CommandTimeout(Exception):
  20. def __init__(self, timeout):
  21. self.timeout = timeout
  22. message = 'Command failed to finish in %s seconds' % (timeout)
  23. self.message = message
  24. super(CommandTimeout, self).__init__(message)