Skip to content

Commit 468f3b3

Browse files
committed
scripts: west_commands: add JSON excepthook
To be used with west commands implementing a jsonschema based protocol. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 2a97534 commit 468f3b3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@
656656
/scripts/ncs-toolchain-version-minimum.txt @nrfconnect/ncs-co-build-system @nrfconnect/ncs-ci
657657
/scripts/tools-versions-*.txt @nrfconnect/ncs-co-build-system @nrfconnect/ncs-ci
658658
/scripts/requirements-*.txt @nrfconnect/ncs-co-build-system @nrfconnect/ncs-ci
659+
/scripts/west_commands/utils/ @gmarull
659660
/scripts/west_commands/create_board/ @gmarull
660661
/scripts/west_commands/ncs-bicr.py @gmarull
661662
/scripts/west_commands/ncs-board-actions.py @gmarull
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
import json
5+
import sys
6+
import traceback
7+
8+
9+
def install_json_excepthook():
10+
def excepthook(type, value, tb):
11+
output = {
12+
"errors": [
13+
{
14+
"type": type.__name__,
15+
"message": str(value),
16+
"traceback": "".join(traceback.format_tb(tb))
17+
}
18+
]
19+
}
20+
21+
print(json.dumps(output, indent=2), file=sys.stderr)
22+
sys.exit(1)
23+
24+
sys.excepthook = excepthook

0 commit comments

Comments
 (0)