mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-06 06:41:56 +00:00
Structure SSE update patches
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
import type { Machine } from '../types/api'
|
||||
|
||||
function getLastSpawnError(runnerState: unknown): { message: string; at?: number } | null {
|
||||
if (!runnerState || typeof runnerState !== 'object' || Array.isArray(runnerState)) {
|
||||
return null
|
||||
}
|
||||
const lastSpawnError = (runnerState as { lastSpawnError?: unknown }).lastSpawnError
|
||||
if (!lastSpawnError || typeof lastSpawnError !== 'object' || Array.isArray(lastSpawnError)) {
|
||||
return null
|
||||
}
|
||||
const message = (lastSpawnError as { message?: unknown }).message
|
||||
if (typeof message !== 'string' || message.length === 0) {
|
||||
return null
|
||||
}
|
||||
const at = (lastSpawnError as { at?: unknown }).at
|
||||
return typeof at === 'number' ? { message, at } : { message }
|
||||
}
|
||||
|
||||
export function formatRunnerSpawnError(machine: Machine | null): string | null {
|
||||
const lastSpawnError = machine?.runnerState?.lastSpawnError
|
||||
if (!lastSpawnError?.message) {
|
||||
const lastSpawnError = getLastSpawnError(machine?.runnerState)
|
||||
if (!lastSpawnError) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user