Skip to content

Commit 80a2c14

Browse files
fix(core): handle an error inside parseProviders() when providerId not found in config (#12438)
fix(core): handle an error inside `parseProviders()` when `providerId` not found in config.
1 parent 7f2c94f commit 80a2c14

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/core/src/lib/utils/providers.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,15 @@ export default function parseProviders(params: {
6262
return merged as InternalProvider
6363
})
6464

65-
return {
66-
providers,
67-
provider: providers.find(({ id }) => id === providerId),
65+
const provider = providers.find(({ id }) => id === providerId)
66+
if (providerId && !provider) {
67+
const availableProviders = providers.map((p) => p.id).join(", ")
68+
throw new Error(
69+
`Provider with id "${providerId}" not found. Available providers: [${availableProviders}].`
70+
)
6871
}
72+
73+
return { providers, provider }
6974
}
7075

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

0 commit comments

Comments
 (0)