MCPcopy Index your code
hub / github.com/codeaashu/claude-code / handlePluginCommandError

Function handlePluginCommandError

src/services/plugins/pluginCliCommands.ts:53–96  ·  view source on GitHub ↗

* Generic error handler for plugin CLI commands. Emits * tengu_plugin_command_failed before exit so dashboards can compute a * success rate against the corresponding success events.

(
  error: unknown,
  command: PluginCliCommand,
  plugin?: string,
)

Source from the content-addressed store, hash-verified

51 * success rate against the corresponding success events.
52 */
53function handlePluginCommandError(
54 error: unknown,
55 command: PluginCliCommand,
56 plugin?: string,
57): never {
58 logError(error)
59 const operation = plugin
60 ? `${command} plugin "${plugin}"`
61 : command === 'disable-all'
62 ? 'disable all plugins'
63 : `${command} plugins`
64 // biome-ignore lint/suspicious/noConsole:: intentional console output
65 console.error(
66 `${figures.cross} Failed to ${operation}: ${errorMessage(error)}`,
67 )
68 const telemetryFields = plugin
69 ? (() => {
70 const { name, marketplace } = parsePluginIdentifier(plugin)
71 return {
72 _PROTO_plugin_name:
73 name as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED,
74 ...(marketplace && {
75 _PROTO_marketplace_name:
76 marketplace as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED,
77 }),
78 ...buildPluginTelemetryFields(
79 name,
80 marketplace,
81 getManagedPluginNames(),
82 ),
83 }
84 })()
85 : {}
86 logEvent('tengu_plugin_command_failed', {
87 command:
88 command as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
89 error_category: classifyPluginCommandError(
90 error,
91 ) as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
92 ...telemetryFields,
93 })
94 // eslint-disable-next-line custom-rules/no-process-exit
95 process.exit(1)
96}
97
98/**
99 * CLI command: Install a plugin non-interactively

Callers 6

installPluginFunction · 0.85
uninstallPluginFunction · 0.85
enablePluginFunction · 0.85
disablePluginFunction · 0.85
disableAllPluginsFunction · 0.85
updatePluginCliFunction · 0.85

Calls 8

parsePluginIdentifierFunction · 0.85
getManagedPluginNamesFunction · 0.85
logEventFunction · 0.85
logErrorFunction · 0.50
errorMessageFunction · 0.50
errorMethod · 0.45

Tested by

no test coverage detected