refactor: more modular error handling in fetchModelsFromProvider function
This commit is contained in:
parent
f35e6cdae8
commit
9a68631d39
@ -182,13 +182,16 @@ export const fetchModelsFromProvider = async (
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching models from provider:', error)
|
console.error('Error fetching models from provider:', error)
|
||||||
|
|
||||||
if (error instanceof Error && (
|
const structuredErrorPrefixes = [
|
||||||
error.message.includes('Authentication failed') ||
|
'Authentication failed',
|
||||||
error.message.includes('Access forbidden') ||
|
'Access forbidden',
|
||||||
error.message.includes('Models endpoint not found') ||
|
'Models endpoint not found',
|
||||||
error.message.includes('Failed to fetch models from')
|
'Failed to fetch models from'
|
||||||
)) {
|
]
|
||||||
throw error
|
|
||||||
|
if (error instanceof Error &&
|
||||||
|
structuredErrorPrefixes.some(prefix => (error as Error).message.startsWith(prefix))) {
|
||||||
|
throw new Error(error.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide helpful error message for network issues
|
// Provide helpful error message for network issues
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user