MCPcopy Index your code
hub / github.com/Noumena-Network/code / handlePluginCommandError

Function handlePluginCommandError

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

* Generic error handler for plugin CLI commands. Emits * ncode_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

52 * success rate against the corresponding success events.
53 */
54function handlePluginCommandError(
55 error: unknown,
56 command: PluginCliCommand,
57 plugin?: string,
58): never {
59 logError(error)
60 const operation = plugin
61 ? `${command} plugin "${plugin}"`
62 : command === 'disable-all'
63 ? 'disable all plugins'
64 : `${command} plugins`
65 // biome-ignore lint/suspicious/noConsole:: intentional console output
66 console.error(
67 `${figures.cross} Failed to ${operation}: ${errorMessage(error)}`,
68 )
69 const telemetryFields = plugin
70 ? (() => {
71 const { name, marketplace } = parsePluginIdentifier(plugin)
72 return {
73 _PROTO_plugin_name:
74 name as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED,
75 ...(marketplace && {
76 _PROTO_marketplace_name:
77 marketplace as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED,
78 }),
79 ...buildPluginTelemetryFields(
80 name,
81 marketplace,
82 getManagedPluginNames(),
83 ),
84 }
85 })()
86 : {}
87 logEvent('ncode_plugin_command_failed', {
88 command:
89 command as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
90 error_category: classifyPluginCommandError(
91 error,
92 ) as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
93 ...telemetryFields,
94 })
95 cliError()
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 9

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

Tested by

no test coverage detected