1# DExTer : Debugging Experience Tester 2# ~~~~~~ ~ ~~ ~ ~~ 3# 4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5# See https://llvm.org/LICENSE.txt for license information. 6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7"""Provides Dexter-specific exception types.""" 8 9 10class Dexception(Exception): 11 """All dexter-specific exceptions derive from this.""" 12 pass 13 14 15class Error(Dexception): 16 """Error. Prints 'error: <message>' without a traceback.""" 17 pass 18 19 20class DebuggerException(Dexception): 21 """Any error from using the debugger.""" 22 23 def __init__(self, msg, orig_exception=None): 24 super(DebuggerException, self).__init__(msg) 25 self.msg = msg 26 self.orig_exception = orig_exception 27 28 def __str__(self): 29 return str(self.msg) 30 31 32class LoadDebuggerException(DebuggerException): 33 """If specified debugger cannot be loaded.""" 34 pass 35 36 37class NotYetLoadedDebuggerException(LoadDebuggerException): 38 """If specified debugger has not yet been attempted to load.""" 39 40 def __init__(self): 41 super(NotYetLoadedDebuggerException, 42 self).__init__('not loaded', orig_exception=None) 43 44 45class CommandParseError(Dexception): 46 """If a command instruction cannot be successfully parsed.""" 47 48 def __init__(self, *args, **kwargs): 49 super(CommandParseError, self).__init__(*args, **kwargs) 50 self.filename = None 51 self.lineno = None 52 self.info = None 53 self.src = None 54 self.caret = None 55 56 57class ToolArgumentError(Dexception): 58 """If a tool argument is invalid.""" 59 pass 60 61 62class BuildScriptException(Dexception): 63 """If there is an error in a build script file.""" 64 65 def __init__(self, *args, **kwargs): 66 self.script_error = kwargs.pop('script_error', None) 67 super(BuildScriptException, self).__init__(*args, **kwargs) 68 69 70class HeuristicException(Dexception): 71 """If there was a problem with the heuristic.""" 72 pass 73