Skip to content

Commit 3dc112c

Browse files
committed
refactor(utils): split errors.ts into separate files
- Split StackOneError into error-stackone.ts - Split StackOneAPIError into error-stackone-api.ts - Remove re-export file errors.ts - Update all imports to use direct paths Improves searchability and code organisation.
1 parent 4c89e91 commit 3dc112c

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

src/feedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { z } from 'zod';
22
import { DEFAULT_BASE_URL } from './consts';
33
import { BaseTool } from './tool';
44
import type { ExecuteConfig, ExecuteOptions, JsonObject, JsonValue, ToolParameters } from './types';
5-
import { StackOneError } from './utils/errors';
5+
import { StackOneError } from './utils/error-stackone';
66

77
interface FeedbackToolOptions {
88
baseUrl?: string;

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
export { BaseTool, StackOneTool, Tools } from './tool';
66
export { createFeedbackTool } from './feedback';
7-
export { StackOneAPIError, StackOneError } from './utils/errors';
7+
export { StackOneError } from './utils/error-stackone';
8+
export { StackOneAPIError } from './utils/error-stackone-api';
89

910
export {
1011
StackOneToolSet,

src/requestBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
type JsonObject,
88
ParameterLocation,
99
} from './types';
10-
import { StackOneAPIError } from './utils/errors';
10+
import { StackOneAPIError } from './utils/error-stackone-api';
1111

1212
interface SerializationOptions {
1313
maxDepth?: number;

src/rpc-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
rpcActionResponseSchema,
99
rpcClientConfigSchema,
1010
} from './schema';
11-
import { StackOneAPIError } from './utils/errors';
11+
import { StackOneAPIError } from './utils/error-stackone-api';
1212

1313
// Re-export types for consumers and to make types portable
1414
export type { RpcActionResponse } from './schema';

src/tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
ToolParameters,
2121
} from './types';
2222

23-
import { StackOneError } from './utils/errors';
23+
import { StackOneError } from './utils/error-stackone';
2424
import { TfidfIndex } from './utils/tfidf-index';
2525
import { tryImport } from './utils/try-import';
2626

src/toolsets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
RpcExecuteConfig,
1414
ToolParameters,
1515
} from './types';
16-
import { StackOneError } from './utils/errors';
16+
import { StackOneError } from './utils/error-stackone';
1717

1818
/**
1919
* Converts RpcActionResponse to JsonObject in a type-safe manner.
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { USER_AGENT } from '../consts';
2-
3-
/**
4-
* Base exception for StackOne errors
5-
*/
6-
export class StackOneError extends Error {
7-
constructor(message: string, options?: ErrorOptions) {
8-
super(message, options);
9-
this.name = 'StackOneError';
10-
}
11-
}
2+
import { StackOneError } from './error-stackone';
123

134
/**
145
* Raised when the StackOne API returns an error

src/utils/error-stackone.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Base exception for StackOne errors
3+
*/
4+
export class StackOneError extends Error {
5+
constructor(message: string, options?: ErrorOptions) {
6+
super(message, options);
7+
this.name = 'StackOneError';
8+
}
9+
}

src/utils/try-import.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StackOneError } from './errors';
1+
import { StackOneError } from './error-stackone';
22

33
/**
44
* Dynamically import an optional dependency with a friendly error message

0 commit comments

Comments
 (0)