refactor: standardize error handling with toError() helper

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-08 21:44:17 +00:00
co-authored by Claude Opus 4.6
parent ea716c1f0e
commit 4d1e592365
4 changed files with 9 additions and 6 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import { db, schema } from '../db/index.js'
import { runMockFight } from './mock.js'
import { eq } from 'drizzle-orm'
import { pick } from '../lib/utils.js'
import { pick, toError } from '../lib/utils.js'
import { fightEvents } from './events.js'
export interface FightResult {
@@ -137,7 +137,7 @@ export async function startFightLoop(options: FightLoopOptions = {}): Promise<vo
}
} catch (err) {
if (onError) {
onError(err instanceof Error ? err : new Error(String(err)))
onError(toError(err))
} else {
console.error('[fight-loop] error:', err)
}