summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2023-07-31 09:34:19 +1000
committerGitHub <noreply@github.com>2023-07-31 09:34:19 +1000
commit030511ece33bfe08307ce519219fde9ab3077cff (patch)
tree6392b04dea7b5e906612c8d393d08466d8d69917 /lib
parentfa4d51dab735ae195e93ded9ab4210ef9852107b (diff)
CLI: Improve error messages when layout key matrix row/col is OOB (#21640)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/generate/keyboard_h.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/python/qmk/cli/generate/keyboard_h.py b/lib/python/qmk/cli/generate/keyboard_h.py
index fa4036e39a..b9e89032b9 100755
--- a/lib/python/qmk/cli/generate/keyboard_h.py
+++ b/lib/python/qmk/cli/generate/keyboard_h.py
@@ -37,14 +37,19 @@ def _generate_layouts(keyboard, kb_info_json):
row, col = key_data['matrix']
identifier = f'k{ROW_LETTERS[row]}{COL_LETTERS[col]}'
- try:
- layout_matrix[row][col] = identifier
- layout_keys.append(identifier)
- except IndexError:
+ if row >= row_num or col >= col_num:
key_name = key_data.get('label', identifier)
- cli.log.error(f'{keyboard}/{layout_name}: Matrix data out of bounds at index {index} ({key_name}): [{row}, {col}]')
+ if row >= row_num:
+ cli.log.error(f'{keyboard}/{layout_name}: Matrix row for key {index} ({key_name}) is {row} but must be less than {row_num}')
+
+ if col >= col_num:
+ cli.log.error(f'{keyboard}/{layout_name}: Matrix column for key {index} ({key_name}) is {col} but must be less than {col_num}')
+
return []
+ layout_matrix[row][col] = identifier
+ layout_keys.append(identifier)
+
lines.append('')
lines.append(f'#define {layout_name}({", ".join(layout_keys)}) {{ \\')