refactor: fold query error seam types into factory module
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user