Skip to content

Commit

Permalink
fix(core): handle an error inside parseProviders() when `providerId…
Browse files Browse the repository at this point in the history
…` not found in config.
  • Loading branch information
KostyaTretyak committed Dec 30, 2024
1 parent 6bd0f96 commit 58c73d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/core/src/lib/utils/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ export default function parseProviders(params: {
return merged as InternalProvider
})

return {
providers,
provider: providers.find(({ id }) => id === providerId),
const provider = providers.find(({ id }) => id === providerId)
if (providerId && !provider) {
const availableProviders = providers.map((p) => p.id).join(", ")
throw new Error(
`Provider with id "${providerId}" not found. Available providers: [${availableProviders}].`
)
}

return { providers, provider }
}

// TODO: Also add discovery here, if some endpoints/config are missing.
Expand Down

0 comments on commit 58c73d7

Please sign in to comment.