-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
Problem Description
Across multiple AI provider implementations (OpenAI, Anthropic, vLLM, etc.), errors are currently handled by instantiating a standard Error object and dynamically attaching a timing property to it. Since the standard Error interface does not include timing, this is achieved using // @ts-ignore to bypass TypeScript validation.
Example from apps/sim/providers/openai/index.ts:
const enhancedError = new Error(error instanceof Error ? error.message : String(error))
// @ts-ignore - Adding timing property to the error
enhancedError.timing = {
startTime: providerStartTimeISO,
endTime: providerEndTimeISO,
duration: totalDuration,
}
throw enhancedErrorThis pattern is repeated in approximately 13 provider files. It weakens type safety, relies on "any" casting (via ignore), and makes the error contract implicit rather than explicit.
Why this matters
- Type Safety: Removing @ ts-ignore ensures that we are not inadvertently suppressing other potential type errors.
- Maintainability: A proper ProviderError interface makes the code self-documenting and easier to refactor.
- Consistency: Centralizing the error definition ensures all providers return errors with the same structure.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels