chore: cleanup and lint fix

This commit is contained in:
RainbowBird
2026-06-07 20:31:22 +08:00
parent 4de2aef746
commit 9382a12137
121 changed files with 846 additions and 264 deletions
+1
View File
@@ -41,6 +41,7 @@
},
"dependencies": {
"@moeru/eventa": "catalog:",
"@moeru/std": "catalog:",
"@proj-airi/plugin-protocol": "workspace:*",
"@proj-airi/server-shared": "workspace:*",
"nanoid": "catalog:",
+3 -2
View File
@@ -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)
}