Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add option to not throw error on user error in dvc js and react #1040

Closed
wants to merge 1 commit into from

Conversation

jsalaber
Copy link
Contributor

@jsalaber jsalaber commented Mar 25, 2025

Changes

  • added option to js sdk to not throw UserError if the user specifies option

Copy link

vercel bot commented Mar 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-sdks-web-elements ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2025 7:09pm
js-sdks-with-provider ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2025 7:09pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
js-sdks-next-js-page-router ⬜️ Ignored (Inspect) Mar 25, 2025 7:09pm

@@ -105,7 +105,7 @@ export function initializeDevCycle<
| DevCycleOptionsWithDeferredInitialization,
optionsArg: DevCycleOptions = {},
): DevCycleClient<Variables, CustomData> {
if (!sdkKey) {
if (!sdkKey && optionsArg?.throwOnError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change this to have an IF statement inside which will at least this.logger.error instead of failing silently?

Also the throwOnError should default to true as that is our existing behaviour.

Suggested change
if (!sdkKey && optionsArg?.throwOnError) {
if (!sdkKey) {
if (optionsArg?.throwOnError) {
throw new UserError(
'Missing SDK key! Call initialize with a valid SDK key',
)
} else {
this.logger.error('Missing SDK key! Call initialize with a valid SDK key)
}
}

let sdkKey: string
if ('sdkKey' in config) {
sdkKey = config.sdkKey
} else {
sdkKey = config.envKey
}
if (!sdkKey) {
if (!sdkKey && !options?.throwOnError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to previous, split this into a nested IF which will log an error if the key is missing but throwOnError is false

@jsalaber jsalaber closed this Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants