Skip to content

Commit 6ba842b

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 242f8c0 commit 6ba842b

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
@@ -658,6 +658,7 @@
658658
/scripts/ncs-toolchain-version-minimum.txt @nrfconnect/ncs-co-build-system @nrfconnect/ncs-ci
659659
/scripts/tools-versions-*.txt @nrfconnect/ncs-co-build-system @nrfconnect/ncs-ci
660660
/scripts/requirements-*.txt @nrfconnect/ncs-co-build-system @nrfconnect/ncs-ci
661+
/scripts/west_commands/utils/ @gmarull
661662
/scripts/west_commands/create_board/ @gmarull
662663
/scripts/west_commands/ncs-bicr.py @gmarull
663664
/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)