summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/c2json.py
diff options
context:
space:
mode:
authorErovia <Erovia@users.noreply.github.com>2021-05-27 17:42:38 +0100
committerGitHub <noreply@github.com>2021-05-27 17:42:38 +0100
commit84883d340045c50ce6c200c9087461c1db853898 (patch)
tree7cdcc263baa2fc387f0f622c431523a9ee6aa7ec /lib/python/qmk/cli/c2json.py
parent147cf8afbb3f7f9b09623c50e42fd3dec76d2147 (diff)
downloadqmk_firmware-84883d340045c50ce6c200c9087461c1db853898.tar.gz
qmk_firmware-84883d340045c50ce6c200c9087461c1db853898.zip
CLI/c2json: Print 'cpp' error when executed in verbose mode (#12869)
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'lib/python/qmk/cli/c2json.py')
-rw-r--r--lib/python/qmk/cli/c2json.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/python/qmk/cli/c2json.py b/lib/python/qmk/cli/c2json.py
index e66b0a1b58..43110a9387 100644
--- a/lib/python/qmk/cli/c2json.py
+++ b/lib/python/qmk/cli/c2json.py
@@ -9,6 +9,7 @@ import qmk.keymap
import qmk.path
from qmk.json_encoders import InfoJSONEncoder
from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.errors import CppError
@cli.argument('--no-cpp', arg_only=True, action='store_false', help='Do not use \'cpp\' on keymap.c')
@@ -37,7 +38,13 @@ def c2json(cli):
cli.args.output = None
# Parse the keymap.c
- keymap_json = qmk.keymap.c2json(cli.args.keyboard, cli.args.keymap, cli.args.filename, use_cpp=cli.args.no_cpp)
+ try:
+ keymap_json = qmk.keymap.c2json(cli.args.keyboard, cli.args.keymap, cli.args.filename, use_cpp=cli.args.no_cpp)
+ except CppError as e:
+ if cli.config.general.verbose:
+ cli.log.debug('The C pre-processor ran into a fatal error: %s', e)
+ cli.log.error('Something went wrong. Try to use --no-cpp.\nUse the CLI in verbose mode to find out more.')
+ return False
# Generate the keymap.json
try: