refactor: fold query error seam types into factory module

This commit is contained in:
Tom Boucher
2026-05-04 20:21:51 -04:00
parent 0fffc7c055
commit ace241d0c2
4 changed files with 29 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
import { formatQueryRawOutput } from './query-raw-output-projection.js';
import { GSDToolsError } from './gsd-tools-error.js';
import { errorMessage, timeoutMessage } from './query-failure-classification.js';
import type { QueryNativeErrorFactory } from './query-tools-error-seam.js';
import type { QueryNativeErrorFactory } from './query-tools-error-factory.js';
import type { QueryResult } from './query/utils.js';
export interface QueryNativeDirectAdapterDeps extends QueryNativeErrorFactory {

View File

@@ -1,7 +1,7 @@
import { execFile } from 'node:child_process';
import { readFile } from 'node:fs/promises';
import { timeoutMessage } from './query-failure-classification.js';
import type { QueryToolsErrorFactory } from './query-tools-error-seam.js';
import type { QueryToolsErrorFactory } from './query-tools-error-factory.js';
export interface QuerySubprocessAdapterDeps extends QueryToolsErrorFactory {
projectDir: string;

View File

@@ -1,7 +1,33 @@
import { GSDError, exitCodeFor } from './errors.js';
import { GSDToolsError } from './gsd-tools-error.js';
import { errorMessage, toFailureSignal } from './query-failure-classification.js';
import type { QueryNativeErrorFactory, QueryToolsErrorFactory } from './query-tools-error-seam.js';
export interface QueryTimeoutErrorFactory {
createTimeoutError: (
message: string,
command: string,
args: string[],
stderr: string,
timeoutMs: number,
) => GSDToolsError;
}
export interface QueryFailureErrorFactory {
createFailureError: (
message: string,
command: string,
args: string[],
exitCode: number | null,
stderr: string,
) => GSDToolsError;
}
export type QueryToolsErrorFactory = QueryTimeoutErrorFactory & QueryFailureErrorFactory;
export interface QueryNativeErrorFactory {
createNativeTimeoutError: (message: string, command: string, args: string[]) => GSDToolsError;
createNativeFailureError: (message: string, command: string, args: string[], cause: unknown) => GSDToolsError;
}
export function timeoutToolsError(message: string, command: string, args: string[], stderr = '', timeoutMs?: number): GSDToolsError {
return GSDToolsError.timeout(message, command, args, stderr, timeoutMs);

View File

@@ -1,28 +0,0 @@
import type { GSDToolsError } from './gsd-tools-error.js';
export interface QueryTimeoutErrorFactory {
createTimeoutError: (
message: string,
command: string,
args: string[],
stderr: string,
timeoutMs: number,
) => GSDToolsError;
}
export interface QueryFailureErrorFactory {
createFailureError: (
message: string,
command: string,
args: string[],
exitCode: number | null,
stderr: string,
) => GSDToolsError;
}
export type QueryToolsErrorFactory = QueryTimeoutErrorFactory & QueryFailureErrorFactory;
export interface QueryNativeErrorFactory {
createNativeTimeoutError: (message: string, command: string, args: string[]) => GSDToolsError;
createNativeFailureError: (message: string, command: string, args: string[], cause: unknown) => GSDToolsError;
}