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