refactor: remove query tools error mapper wrapper
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
import type { InitNewProjectInfo, PhaseOpInfo, PhasePlanIndex, RoadmapAnalysis } from './types.js';
|
import type { InitNewProjectInfo, PhaseOpInfo, PhasePlanIndex, RoadmapAnalysis } from './types.js';
|
||||||
import type { GSDEventStream } from './event-stream.js';
|
import type { GSDEventStream } from './event-stream.js';
|
||||||
import { toGSDToolsError } from './query-tools-error-mapper.js';
|
import { toToolsErrorFromUnknown } from './query-tools-error-factory.js';
|
||||||
import { GSDToolsError } from './gsd-tools-error.js';
|
import { GSDToolsError } from './gsd-tools-error.js';
|
||||||
import { resolveQueryCommand, type QueryCommandResolution } from './query/query-command-resolution-strategy.js';
|
import { resolveQueryCommand, type QueryCommandResolution } from './query/query-command-resolution-strategy.js';
|
||||||
import { QueryExecutionPolicy } from './query-execution-policy.js';
|
import { QueryExecutionPolicy } from './query-execution-policy.js';
|
||||||
@@ -108,7 +108,7 @@ export class GSDTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private toToolsError(command: string, args: string[], err: unknown): GSDToolsError {
|
private toToolsError(command: string, args: string[], err: unknown): GSDToolsError {
|
||||||
return toGSDToolsError(command, args, err);
|
return toToolsErrorFromUnknown(command, args, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async dispatchNativeHotpath(
|
private async dispatchNativeHotpath(
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { ErrorClassification, GSDError } from './errors.js';
|
import { ErrorClassification, GSDError } from './errors.js';
|
||||||
import { toGSDToolsError } from './query-tools-error-mapper.js';
|
import { toToolsErrorFromUnknown } from './query-tools-error-factory.js';
|
||||||
|
|
||||||
describe('query tools error mapper', () => {
|
describe('query tools error mapper', () => {
|
||||||
it('maps GSDError to GSDToolsError exit code', () => {
|
it('maps GSDError to GSDToolsError exit code', () => {
|
||||||
const err = toGSDToolsError('state', ['load'], new GSDError('bad input', ErrorClassification.Validation));
|
const err = toToolsErrorFromUnknown('state', ['load'], new GSDError('bad input', ErrorClassification.Validation));
|
||||||
expect(err.exitCode).toBe(10);
|
expect(err.exitCode).toBe(10);
|
||||||
expect(err.message).toBe('bad input');
|
expect(err.message).toBe('bad input');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('attaches timeout classification when message indicates timeout', () => {
|
it('attaches timeout classification when message indicates timeout', () => {
|
||||||
const err = toGSDToolsError('state', ['load'], new Error('gsd-tools timed out after 1234ms: state load'));
|
const err = toToolsErrorFromUnknown('state', ['load'], new Error('gsd-tools timed out after 1234ms: state load'));
|
||||||
expect(err.classification).toEqual({ kind: 'timeout', timeoutMs: 1234 });
|
expect(err.classification).toEqual({ kind: 'timeout', timeoutMs: 1234 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('attaches failure classification for non-timeout failures', () => {
|
it('attaches failure classification for non-timeout failures', () => {
|
||||||
const err = toGSDToolsError('state', ['load'], new Error('boom'));
|
const err = toToolsErrorFromUnknown('state', ['load'], new Error('boom'));
|
||||||
expect(err.classification).toEqual({ kind: 'failure' });
|
expect(err.classification).toEqual({ kind: 'failure' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { toToolsErrorFromUnknown } from './query-tools-error-factory.js';
|
|
||||||
import type { GSDToolsError } from './gsd-tools-error.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module owning projection of internal errors to GSDToolsError contract.
|
|
||||||
*/
|
|
||||||
export function toGSDToolsError(command: string, args: string[], err: unknown): GSDToolsError {
|
|
||||||
return toToolsErrorFromUnknown(command, args, err);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user