mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
- Refactor HealthDaemon to use a tracked session (AbortController + awaitable promise) instead of fire-and-forget health check loops, preventing health checks from running after a service is stopped - Stop health checks before terminating daemon to avoid false crash reports during intentional shutdown - Guard onExit callbacks with AbortSignal to prevent stale session callbacks - Add logErrorOnce utility to deduplicate repeated error logging - Fix SystemForEmbassy.stop() to capture clean promise before deleting ref - Treat SIGTERM (signal 15) as successful exit in subcontainer sync - Fix asError to return original Error instead of wrapping in new Error - Remove unused ExtendedVersion import from Backups.ts
18 lines
471 B
TypeScript
18 lines
471 B
TypeScript
/**
|
|
* Converts an unknown thrown value into an Error instance.
|
|
* If `e` is already an Error, wraps it; if a string, uses it as the message;
|
|
* otherwise JSON-serializes it as the error message.
|
|
*
|
|
* @param e - The unknown value to convert
|
|
* @returns An Error instance
|
|
*/
|
|
export const asError = (e: unknown) => {
|
|
if (e instanceof Error) {
|
|
return e
|
|
}
|
|
if (typeof e === 'string') {
|
|
return new Error(`${e}`)
|
|
}
|
|
return new Error(`${JSON.stringify(e)}`)
|
|
}
|