diff --git a/gprMax/exceptions.py b/gprMax/exceptions.py index 57a1c15b..838ffdb5 100644 --- a/gprMax/exceptions.py +++ b/gprMax/exceptions.py @@ -17,33 +17,28 @@ # along with gprMax. If not, see . import logging -import sys from colorama import init from colorama import Fore init() log = logging.getLogger(__name__) -sys.tracebacklimit = None class GeneralError(ValueError): """Handles general errors. Subclasses the ValueError class.""" - def __init__(self, message, *args): - self.message = message super(GeneralError, self).__init__(message, *args) log.exception(Fore.RED) -class CmdInputError(ValueError): +class CmdInputError(Exception): """Handles errors in user specified commands. Subclasses the ValueError class. """ - - def __init__(self, message, *args): - - self.message = message - super(CmdInputError, self).__init__(message, *args) - log.exception(Fore.RED) + pass + # def __init__(self, message, *args): + # self.message = message + # super(CmdInputError, self).__init__(message, *args) + # log.exception(Fore.RED) diff --git a/gprMax/gprMax.py b/gprMax/gprMax.py index fe279e12..c5659c99 100644 --- a/gprMax/gprMax.py +++ b/gprMax/gprMax.py @@ -22,6 +22,9 @@ import logging from .config_parser import write_simulation_config from .contexts import create_context +# Configure logging +log = logging.getLogger(__name__) +# logging.basicConfig(level=logging.DEBUG, format='%(module)s %(lineno)d %(message)s') logging.basicConfig(level=logging.INFO, format='%(message)s') @@ -133,7 +136,10 @@ def run( args.geometry_fixed = geometry_fixed args.write_processed = write_processed - run_main(args) + try: + run_main(args) + except Exception: + log.exception('Error from main API function', exc_info=True) def main(): @@ -154,8 +160,10 @@ def main(): parser.add_argument('--write-processed', action='store_true', default=False, help='flag to write an input file after any Python code and include commands in the original input file have been processed') args = parser.parse_args() - run_main(args) - + try: + run_main(args) + except Exception: + log.exception('Error from main CLI function', exc_info=True) def run_main(args): """Called by either run (API) or main (CLI).