feat: add debug logging for silently caught errors (#809)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Loads and matches hooks from settings-manager
|
||||
|
||||
import { settingsManager } from "../settings-manager";
|
||||
import { debugLog } from "../utils/debug";
|
||||
import {
|
||||
type HookCommand,
|
||||
type HookEvent,
|
||||
@@ -27,8 +28,9 @@ export function clearHooksCache(): void {
|
||||
export function loadGlobalHooks(): HooksConfig {
|
||||
try {
|
||||
return settingsManager.getSettings().hooks || {};
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// Settings not initialized yet
|
||||
debugLog("hooks", "loadGlobalHooks: Settings not initialized yet", error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -48,8 +50,9 @@ export async function loadProjectHooks(
|
||||
await settingsManager.loadProjectSettings(workingDirectory);
|
||||
}
|
||||
return settingsManager.getProjectSettings(workingDirectory)?.hooks || {};
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// Settings not available
|
||||
debugLog("hooks", "loadProjectHooks: Settings not available", error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -71,8 +74,9 @@ export async function loadProjectLocalHooks(
|
||||
return (
|
||||
settingsManager.getLocalProjectSettings(workingDirectory)?.hooks || {}
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// Settings not available
|
||||
debugLog("hooks", "loadProjectLocalHooks: Settings not available", error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -162,8 +166,13 @@ export function matchesTool(pattern: string, toolName: string): boolean {
|
||||
try {
|
||||
const regex = new RegExp(`^(?:${pattern})$`);
|
||||
return regex.test(toolName);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// Invalid regex, fall back to exact match
|
||||
debugLog(
|
||||
"hooks",
|
||||
`matchesTool: Invalid regex pattern "${pattern}", falling back to exact match`,
|
||||
error,
|
||||
);
|
||||
return pattern === toolName;
|
||||
}
|
||||
}
|
||||
@@ -270,8 +279,13 @@ export function areHooksDisabled(
|
||||
if (projectDisabled === true) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// Project settings not loaded, skip
|
||||
debugLog(
|
||||
"hooks",
|
||||
"areHooksDisabled: Project settings not loaded, skipping",
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
// Check project-local settings
|
||||
@@ -282,12 +296,22 @@ export function areHooksDisabled(
|
||||
if (localDisabled === true) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// Local project settings not loaded, skip
|
||||
debugLog(
|
||||
"hooks",
|
||||
"areHooksDisabled: Local project settings not loaded, skipping",
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
debugLog(
|
||||
"hooks",
|
||||
"areHooksDisabled: Failed to check hooks disabled status",
|
||||
error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user