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 -1
View File
@@ -1,4 +1,5 @@
import { nanoid } from 'nanoid'
import { toError } from '../lib/utils.js'
import { db, schema, sqlite } from '../db/index.js'
import { eq, sql } from 'drizzle-orm'
import { randomArena, type Arena } from './arenas.js'
@@ -207,7 +208,7 @@ async function callWebhook(
} catch (err: unknown) {
const elapsed = Date.now() - start
const isAbort = err instanceof Error && err.name === 'AbortError'
console.log(`[webhook] ${url} ${isAbort ? "TIMEOUT" : "ERROR"} in ${elapsed}ms: ${err instanceof Error ? err.message : err}`)
console.log(`[webhook] ${url} ${isAbort ? "TIMEOUT" : "ERROR"} in ${elapsed}ms: ${toError(err).message}`)
return {
answer: null,
timeMs: elapsed,