Skip to content

Conversation

fundakol
Copy link
Contributor

@fundakol fundakol commented Oct 9, 2025

Removed redundant try..except around the code
and fixed a test for that code which was false positive.

With this change twister will print an error message without
a stacktrace from twister code, which is more user friendly.
Example:

Renaming previous output directory to /home/workspace/repos/zephyr/twister-out.10
INFO    - Using Ninja..
INFO    - Zephyr version: v4.2.0-5355-ga9be24ce627f
ERROR   - CMake script failure: /home/workspace/repos/zephyr/cmake/verify-toolchain.cmake
E: CMake Error at cmake/modules/FindZephyr-sdk.cmake:159 (find_package):
  Could not find a package configuration file provided by "Zephyr-sdk"
  (requested version 0.16) with any of the following names:

    Zephyr-sdkConfig.cmake
    zephyr-sdk-config.cmake

  Add the installation prefix of "Zephyr-sdk" to CMAKE_PREFIX_PATH or set
  "Zephyr-sdk_DIR" to a directory containing one of the above files.  If
  "Zephyr-sdk" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  cmake/modules/FindHostTools.cmake:51 (find_package)
  cmake/verify-toolchain.cmake:30 (find_package)

Removed redundant try..except around the code
and fixed a test for that code which was false positive.

Signed-off-by: Łukasz Fundakowski <[email protected]>
Copy link

sonarqubecloud bot commented Oct 9, 2025

@hakehuang
Copy link
Contributor

I would not support this change. backtrace is helpful for debug and fixing issue, it is not for user of twister but for developer of twister. Also, original idea of the try and catch is to unify the way to handle twister errors.

@fundakol
Copy link
Contributor Author

I would not support this change. backtrace is helpful for debug and fixing issue, it is not for user of twister but for developer of twister. Also, original idea of the try and catch is to unify the way to handle twister errors.

That try..except was only for 2 lines of code, you won't get any useful backtrace from them.

try:
  if result['returncode']:
    raise TwisterRuntimeError(f"E: {result['returnmsg']}")
except Exception as e:
  print(str(e))

@hakehuang
Copy link
Contributor

I would not support this change. backtrace is helpful for debug and fixing issue, it is not for user of twister but for developer of twister. Also, original idea of the try and catch is to unify the way to handle twister errors.

That try..except was only for 2 lines of code, you won't get any useful backtrace from them.

try:
  if result['returncode']:
    raise TwisterRuntimeError(f"E: {result['returnmsg']}")
except Exception as e:
  print(str(e))

if I remember correctly the error.py in twister handle the stack print

@cfriedt cfriedt merged commit 8201d20 into zephyrproject-rtos:main Oct 13, 2025
61 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants