refactor: isolate native dispatch error projection

This commit is contained in:
Tom Boucher
2026-05-04 20:19:13 -04:00
parent ed9d67c91b
commit b0e616288b

View File

@@ -19,8 +19,7 @@ export class QueryNativeDirectAdapter {
try {
return await this.withTimeout(legacyCommand, legacyArgs, this.deps.dispatch(registryCommand, registryArgs));
} catch (error) {
if (error instanceof GSDToolsError) throw error;
throw this.deps.createNativeFailureError(errorMessage(error), legacyCommand, legacyArgs, error);
throw this.toNativeDispatchError(legacyCommand, legacyArgs, error);
}
}
@@ -34,6 +33,11 @@ export class QueryNativeDirectAdapter {
return formatQueryRawOutput(registryCommand, result.data).trim();
}
private toNativeDispatchError(legacyCommand: string, legacyArgs: string[], error: unknown): GSDToolsError {
if (error instanceof GSDToolsError) return error;
return this.deps.createNativeFailureError(errorMessage(error), legacyCommand, legacyArgs, error);
}
private async withTimeout<T>(legacyCommand: string, legacyArgs: string[], work: Promise<T>): Promise<T> {
let timeoutId: ReturnType<typeof setTimeout> | undefined;
const timeoutPromise = new Promise<never>((_, reject) => {