refactor: standardize error handling with toError() helper
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
ea716c1f0e
commit
4d1e592365
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user