| @@ -292,6 +292,12 @@ const DEFAULT_RESOLVED_KEYBINDINGS = compileDefaultKeybindings(); · 291 unmodified lines |
| 292 | 292 | const KEYBINDINGS_CONFIG_PATH = path.join(".t3", "keybindings.json"); |
| 293 | 293 | const MAX_KEYBINDINGS = 256; |
| 294 | 294 | |
| 295 | +class KeybindingsConfigParseError extends Error { |
| 296 | + constructor(configPath: string, detail: string, options?: { cause?: unknown }) { |
| 297 | + super(`Unable to parse keybindings config at ${configPath}: ${detail}`, options); |
| 298 | + } |
| 299 | +} |
| 300 | + |
| 295 | 301 | function resolveKeybindingsConfigPath(): string { |
| 296 | 302 | return path.join(os.homedir(), KEYBINDINGS_CONFIG_PATH); |
| 297 | 303 | } |
| @@ -308,7 +314,7 @@ function loadCustomKeybindingsConfig( · 10 unmodified lines |
| 308 | 314 | const parsed = JSON.parse(raw) as unknown; |
| 309 | 315 | if (!Array.isArray(parsed)) { |
| 310 | 316 | if (options?.throwOnUnreadableConfig) { |
| 311 | | − throw new Error(`Unable to parse keybindings config at ${configPath}: expected JSON array`); |
| 317 | + throw new KeybindingsConfigParseError(configPath, "expected JSON array"); |
| 312 | 318 | } |
| 313 | 319 | logger.warn("ignoring keybindings config with unsupported format; expected array", { |
| 314 | 320 | path: configPath, |
| @@ -343,10 +349,12 @@ function loadCustomKeybindingsConfig( · 28 unmodified lines |
| 343 | 349 | return []; |
| 344 | 350 | } |
| 345 | 351 | if (options?.throwOnUnreadableConfig) { |
| 346 | | − throw new Error( |
| 347 | | − `Unable to parse keybindings config at ${configPath}: ${ |
| 348 | | − error instanceof Error ? error.message : String(error) |
| 349 | | − }`, |
| 352 | + if (error instanceof KeybindingsConfigParseError) { |
| 353 | + throw error; |
| 354 | + } |
| 355 | + throw new KeybindingsConfigParseError( |
| 356 | + configPath, |
| 357 | + error instanceof Error ? error.message : String(error), |
| 350 | 358 | { cause: error }, |
| 351 | 359 | ); |
| 352 | 360 | } |