88 lines · python
1# DExTer : Debugging Experience Tester2# ~~~~~~ ~ ~~ ~ ~~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-exception7"""Provides Dexter-specific exception types."""8 9 10class Dexception(Exception):11 """All dexter-specific exceptions derive from this."""12 13 pass14 15 16class Error(Dexception):17 """Error. Prints 'error: <message>' without a traceback."""18 19 pass20 21 22class DebuggerException(Dexception):23 """Any error from using the debugger."""24 25 def __init__(self, msg, orig_exception=None):26 super(DebuggerException, self).__init__(msg)27 self.msg = msg28 self.orig_exception = orig_exception29 30 def __str__(self):31 return str(self.msg)32 33 34class LoadDebuggerException(DebuggerException):35 """If specified debugger cannot be loaded."""36 37 pass38 39 40class NotYetLoadedDebuggerException(LoadDebuggerException):41 """If specified debugger has not yet been attempted to load."""42 43 def __init__(self):44 super(NotYetLoadedDebuggerException, self).__init__(45 "not loaded", orig_exception=None46 )47 48 49class CommandParseError(Dexception):50 """If a command instruction cannot be successfully parsed."""51 52 def __init__(self, *args, **kwargs):53 super(CommandParseError, self).__init__(*args, **kwargs)54 self.filename = None55 self.lineno = None56 self.info = None57 self.src = None58 self.caret = None59 60 61class NonFloatValueInCommand(CommandParseError):62 """If a command has the float_range arg but at least one of its expected63 values cannot be converted to a float."""64 65 def __init__(self, *args, **kwargs):66 super(NonFloatValueInCommand, self).__init__(*args, **kwargs)67 self.value = None68 69 70class ToolArgumentError(Dexception):71 """If a tool argument is invalid."""72 73 pass74 75 76class BuildScriptException(Dexception):77 """If there is an error in a build script file."""78 79 def __init__(self, *args, **kwargs):80 self.script_error = kwargs.pop("script_error", None)81 super(BuildScriptException, self).__init__(*args, **kwargs)82 83 84class HeuristicException(Dexception):85 """If there was a problem with the heuristic."""86 87 pass88