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