你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Work to get exceptions propagating correctly.
这个提交包含在:
@@ -17,33 +17,28 @@
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
|
@@ -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).
|
||||
|
在新工单中引用
屏蔽一个用户