Skip to content

Commit 798768e

Browse files
hakehuangkartben
authored andcommitted
twister: add trace print in exception
add trace print when exception happens Signed-off-by: Hake Huang <[email protected]>
1 parent c875582 commit 798768e

File tree

1 file changed

+10
-6
lines changed
  • scripts/pylib/twister/twisterlib

1 file changed

+10
-6
lines changed

scripts/pylib/twister/twisterlib/error.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,32 @@
22
#
33
# Copyright (c) 2018-2022 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
5+
import logging
6+
import traceback
57

6-
class TwisterException(Exception):
7-
pass
8+
logger = logging.getLogger('twister')
9+
logger.setLevel(logging.DEBUG)
810

11+
class TwisterException(Exception):
12+
def __init__(self, message="TwisterException"):
13+
super().__init__(message)
14+
for line in traceback.format_stack():
15+
logger.info(line.strip())
16+
logger.warning("======call stack dump end============")
917

1018
class TwisterRuntimeError(TwisterException):
1119
pass
1220

13-
1421
class ConfigurationError(TwisterException):
1522
def __init__(self, cfile, message):
1623
TwisterException.__init__(self, str(cfile) + ": " + message)
1724

18-
1925
class BuildError(TwisterException):
2026
pass
2127

22-
2328
class ExecutionError(TwisterException):
2429
pass
2530

26-
2731
class StatusAttributeError(TwisterException):
2832
def __init__(self, cls : type, value):
2933
msg = f'{cls.__name__} assigned status {value}, which could not be cast to a TwisterStatus.'

0 commit comments

Comments
 (0)