The base owns the wrapping logic (warning, status -> error-type map,
common message patterns). Providers only contribute their unique parts.
Side effects:
normalizeError now consults mapProviderError before generic mapping,
so provider-specific patterns work via the existing try/catch in
BaseAIProvider.complete/stream. The per-provider try/catch wrappers
around doComplete/doStream are removed.
The unknown-error message becomes ${providerName} error: ${msg}
instead of the hardcoded Provider error: / Claude API error: etc.
OpenWebUI's HTTP-based validateConnection is preserved (override),
since its non-SDK shape doesn't fit the SDK probe pattern.
Form Template Method / Pull Up Method from the Refactoring Guru catalog.
The three SDK-based providers (Claude, OpenAI, Gemini) each had their own
near-identical implementations of:
- validateConnection: try a tiny request, catch errors, map a handful
of patterns, warn on the rest
- validateModelName: iterate regex patterns, warn on no match
- handle{X}Error: switch on HTTP status, map to AIProviderError with
brand-flavored messages
These collapse into three protected hooks on BaseAIProvider:
- getModelNamePatterns(): RegExp[]
- sendValidationProbe(): Promise<void>
- mapProviderError(error): AIProviderError | null
- providerErrorMessages(): Partial<Record<number, string>>
The base owns the wrapping logic (warning, status -> error-type map,
common message patterns). Providers only contribute their unique parts.
Side effects:
- normalizeError now consults mapProviderError before generic mapping,
so provider-specific patterns work via the existing try/catch in
BaseAIProvider.complete/stream. The per-provider try/catch wrappers
around doComplete/doStream are removed.
- The unknown-error message becomes `${providerName} error: ${msg}`
instead of the hardcoded `Provider error:` / `Claude API error:` etc.
- OpenWebUI's HTTP-based validateConnection is preserved (override),
since its non-SDK shape doesn't fit the SDK probe pattern.
Form Template Method / Pull Up Method from the Refactoring Guru catalog.
The three SDK-based providers (Claude, OpenAI, Gemini) each had their own
near-identical implementations of:
- validateConnection: try a tiny request, catch errors, map a handful
of patterns, warn on the rest
- validateModelName: iterate regex patterns, warn on no match
- handle{X}Error: switch on HTTP status, map to AIProviderError with
brand-flavored messages
These collapse into three protected hooks on BaseAIProvider:
- getModelNamePatterns(): RegExp[]
- sendValidationProbe(): Promise<void>
- mapProviderError(error): AIProviderError | null
- providerErrorMessages(): Partial<Record<number, string>>
The base owns the wrapping logic (warning, status -> error-type map,
common message patterns). Providers only contribute their unique parts.
Side effects:
- normalizeError now consults mapProviderError before generic mapping,
so provider-specific patterns work via the existing try/catch in
BaseAIProvider.complete/stream. The per-provider try/catch wrappers
around doComplete/doStream are removed.
- The unknown-error message becomes `${providerName} error: ${msg}`
instead of the hardcoded `Provider error:` / `Claude API error:` etc.
- OpenWebUI's HTTP-based validateConnection is preserved (override),
since its non-SDK shape doesn't fit the SDK probe pattern.
jleibl
merged commit eacd76d259 into main2026-05-21 11:46:55 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Form Template Method / Pull Up Method from the Refactoring Guru catalog.
The three SDK-based providers (Claude, OpenAI, Gemini) each had their own
near-identical implementations of:
of patterns, warn on the rest
brand-flavored messages
These collapse into three protected hooks on BaseAIProvider:
The base owns the wrapping logic (warning, status -> error-type map,
common message patterns). Providers only contribute their unique parts.
Side effects:
so provider-specific patterns work via the existing try/catch in
BaseAIProvider.complete/stream. The per-provider try/catch wrappers
around doComplete/doStream are removed.
${providerName} error: ${msg}instead of the hardcoded
Provider error:/Claude API error:etc.since its non-SDK shape doesn't fit the SDK probe pattern.
Form Template Method / Pull Up Method from the Refactoring Guru catalog. The three SDK-based providers (Claude, OpenAI, Gemini) each had their own near-identical implementations of: - validateConnection: try a tiny request, catch errors, map a handful of patterns, warn on the rest - validateModelName: iterate regex patterns, warn on no match - handle{X}Error: switch on HTTP status, map to AIProviderError with brand-flavored messages These collapse into three protected hooks on BaseAIProvider: - getModelNamePatterns(): RegExp[] - sendValidationProbe(): Promise<void> - mapProviderError(error): AIProviderError | null - providerErrorMessages(): Partial<Record<number, string>> The base owns the wrapping logic (warning, status -> error-type map, common message patterns). Providers only contribute their unique parts. Side effects: - normalizeError now consults mapProviderError before generic mapping, so provider-specific patterns work via the existing try/catch in BaseAIProvider.complete/stream. The per-provider try/catch wrappers around doComplete/doStream are removed. - The unknown-error message becomes `${providerName} error: ${msg}` instead of the hardcoded `Provider error:` / `Claude API error:` etc. - OpenWebUI's HTTP-based validateConnection is preserved (override), since its non-SDK shape doesn't fit the SDK probe pattern.