chore: cleanup and lint fix
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@moeru/eventa": "catalog:",
|
||||
"@moeru/std": "catalog:",
|
||||
"@proj-airi/plugin-protocol": "workspace:*",
|
||||
"@proj-airi/server-shared": "workspace:*",
|
||||
"nanoid": "catalog:",
|
||||
|
||||
@@ -32,6 +32,7 @@ import type { PluginTransport } from './transports'
|
||||
import { cwd } from 'node:process'
|
||||
|
||||
import { defineInvokeHandler } from '@moeru/eventa'
|
||||
import { errorMessageFrom } from '@moeru/std'
|
||||
import {
|
||||
errorPermission,
|
||||
moduleAnnounce,
|
||||
@@ -1320,7 +1321,7 @@ export class PluginHost {
|
||||
session.channels.host.emit(moduleStatus, {
|
||||
identity: session.identity,
|
||||
phase: 'failed',
|
||||
reason: error instanceof Error ? error.message : 'Failed to load plugin.',
|
||||
reason: errorMessageFrom(error) ?? 'Failed to load plugin.',
|
||||
})
|
||||
|
||||
throw error
|
||||
@@ -1568,7 +1569,7 @@ export class PluginHost {
|
||||
session.channels.host.emit(moduleStatus, {
|
||||
identity: session.identity,
|
||||
phase: 'failed',
|
||||
reason: error instanceof Error ? error.message : 'Plugin host initialization failed.',
|
||||
reason: errorMessageFrom(error) ?? 'Plugin host initialization failed.',
|
||||
})
|
||||
|
||||
this.cleanupSession(session)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { errorMessageFrom } from '@moeru/std'
|
||||
|
||||
/**
|
||||
* Returns an error message while preserving JavaScript string fallback.
|
||||
*
|
||||
* Use when:
|
||||
* - Plugin host diagnostics need a message for arbitrary thrown values.
|
||||
*
|
||||
* Expects:
|
||||
* - `error` may be any thrown value.
|
||||
*
|
||||
* Returns:
|
||||
* - The extracted error message, else `String(error)`.
|
||||
*/
|
||||
export function errorMessageFromValue(error: unknown): string {
|
||||
return errorMessageFrom(error) ?? String(error)
|
||||
}
|
||||
Reference in New Issue
Block a user