jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.6KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2010 (ita)
  4. """
  5. Exceptions used in the Waf code
  6. """
  7. import traceback, sys
  8. class WafError(Exception):
  9. """Base class for all Waf errors"""
  10. def __init__(self, msg='', ex=None):
  11. """
  12. :param msg: error message
  13. :type msg: string
  14. :param ex: exception causing this error (optional)
  15. :type ex: exception
  16. """
  17. self.msg = msg
  18. assert not isinstance(msg, Exception)
  19. self.stack = []
  20. if ex:
  21. if not msg:
  22. self.msg = str(ex)
  23. if isinstance(ex, WafError):
  24. self.stack = ex.stack
  25. else:
  26. self.stack = traceback.extract_tb(sys.exc_info()[2])
  27. self.stack += traceback.extract_stack()[:-1]
  28. self.verbose_msg = ''.join(traceback.format_list(self.stack))
  29. def __str__(self):
  30. return str(self.msg)
  31. class BuildError(WafError):
  32. """
  33. Errors raised during the build and install phases
  34. """
  35. def __init__(self, error_tasks=[]):
  36. """
  37. :param error_tasks: tasks that could not complete normally
  38. :type error_tasks: list of task objects
  39. """
  40. self.tasks = error_tasks
  41. WafError.__init__(self, self.format_error())
  42. def format_error(self):
  43. """format the error messages from the tasks that failed"""
  44. lst = ['Build failed']
  45. for tsk in self.tasks:
  46. txt = tsk.format_error()
  47. if txt: lst.append(txt)
  48. return '\n'.join(lst)
  49. class ConfigurationError(WafError):
  50. """
  51. Configuration exception raised in particular by :py:meth:`waflib.Context.Context.fatal`
  52. """
  53. pass
  54. class TaskRescan(WafError):
  55. """task-specific exception type, trigger a signature recomputation"""
  56. pass
  57. class TaskNotReady(WafError):
  58. """task-specific exception type, raised when the task signature cannot be computed"""
  59. pass