From 0503d9ef7d53ae2625a079a4e1cf815301eae4a6 Mon Sep 17 00:00:00 2001 From: SET Date: Wed, 12 Aug 2020 09:48:44 -0300 Subject: [PATCH] Added stack trace for the SCH loading. Only when debug enabled. --- kiplot/error.py | 6 +++++- kiplot/kiplot.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kiplot/error.py b/kiplot/error.py index 64f6b2ac..8dfaa6a3 100644 --- a/kiplot/error.py +++ b/kiplot/error.py @@ -23,10 +23,14 @@ class KiPlotConfigurationError(KiPlotError): pass -def config_error(msg): +def trace_dump(): if GS.debug_enabled: logger.error('Trace stack:') (type, value, traceback) = exc_info() print_tb(traceback) + + +def config_error(msg): + trace_dump() logger.error(msg) exit(EXIT_BAD_CONFIG) diff --git a/kiplot/kiplot.py b/kiplot/kiplot.py index 83e1cb65..8f5963a0 100644 --- a/kiplot/kiplot.py +++ b/kiplot/kiplot.py @@ -14,7 +14,7 @@ from importlib.util import (spec_from_file_location, module_from_spec) from .gs import (GS) from .misc import (PLOT_ERROR, NO_PCBNEW_MODULE, MISSING_TOOL, CMD_EESCHEMA_DO, URL_EESCHEMA_DO, CORRUPTED_PCB, EXIT_BAD_ARGS, CORRUPTED_SCH) -from .error import (PlotError, KiPlotConfigurationError, config_error) +from .error import PlotError, KiPlotConfigurationError, config_error, trace_dump from .pre_base import BasePreFlight from .kicad.v5_sch import Schematic, SchFileError from . import log @@ -127,6 +127,7 @@ def load_sch(): GS.sch.load(GS.sch_file) GS.sch.load_libs(GS.sch_file) except SchFileError as e: + trace_dump() logger.error('At line {} of `{}`: {}'.format(e.args[2], GS.sch_file, e.args[0])) logger.error('Line content: `{}`'.format(e.args[1])) exit(CORRUPTED_SCH)