Skip to content

Commit

Permalink
fix: put more error logs behind debug info setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 5, 2024
1 parent 0217768 commit db49152
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
8 changes: 5 additions & 3 deletions packages/app-backend-api/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginPermission, hasPluginPermission } from '@vue-devtools/shared-utils'
import { PluginPermission, SharedData, hasPluginPermission } from '@vue-devtools/shared-utils'
import type { HookHandler, HookPayloads, Hookable } from '@vue/devtools-api'
import { Hooks } from '@vue/devtools-api'
import type { BackendContext } from './backend-context'
Expand Down Expand Up @@ -59,8 +59,10 @@ export class DevtoolsHookable implements Hookable<BackendContext> {
await handler(payload, ctx)
}
catch (e) {
console.error(`An error occurred in hook '${eventType}'${plugin ? ` registered by plugin '${plugin.descriptor.id}'` : ''} with payload:`, payload)
console.error(e)
if (SharedData.debugInfo) {
console.error(`An error occurred in hook '${eventType}'${plugin ? ` registered by plugin '${plugin.descriptor.id}'` : ''} with payload:`, payload)
console.error(e)
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/app-backend-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ export function _legacy_getAndRegisterApps(ctx: BackendContext, clear = false) {
})
}
catch (e) {
console.error(`Error scanning for legacy apps:`)
console.error(e)
if (SharedData.debugInfo) {
console.error(`Error scanning for legacy apps:`)
console.error(e)
}
}
}, 0)
}
24 changes: 16 additions & 8 deletions packages/app-backend-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,19 @@ async function connect() {
await addPreviouslyRegisteredPlugins(ctx)
}
catch (e) {
console.error(`Error adding previously registered plugins:`)
console.error(e)
if (SharedData.debugInfo) {
console.error(`Error adding previously registered plugins:`)
console.error(e)
}
}
try {
await addQueuedPlugins(ctx)
}
catch (e) {
console.error(`Error adding queued plugins:`)
console.error(e)
if (SharedData.debugInfo) {
console.error(`Error adding queued plugins:`)
console.error(e)
}
}

hook.on(HookEvents.SETUP_DEVTOOLS_PLUGIN, async (pluginDescriptor: PluginDescriptor, setupFn: SetupFunction) => {
Expand Down Expand Up @@ -450,8 +454,10 @@ async function connect() {
}, ctx)
}
catch (e) {
console.error(`Error while adding devtools connected timeline marker:`)
console.error(e)
if (SharedData.debugInfo) {
console.error(`Error while adding devtools connected timeline marker:`)
console.error(e)
}
}
}

Expand Down Expand Up @@ -589,10 +595,12 @@ function connectBridge() {
await action()
}
catch (e) {
console.error(e)
if (SharedData.debugInfo) {
console.error(e)
}
}
}
else {
else if (SharedData.debugInfo) {
console.warn(`Couldn't revive action ${actionIndex} from`, value)
}
})
Expand Down

0 comments on commit db49152

Please sign in to comment.