fix: log unexpected bird failures

This commit is contained in:
2026-07-13 11:08:36 +09:00
parent 65fae12e67
commit 9a93290a5d
3 changed files with 58 additions and 15 deletions
+15 -12
View File
@@ -3,14 +3,17 @@ import { searchPageInputSchema, userPageInputSchema } from './inputs'
import { loadUserPage, searchPage } from './post-service'
import type { LoadResult } from './types'
const configFailure = (): LoadResult => ({
ok: false,
error: {
code: 'relay-config',
message: 'TWITTER_RELAY_BASE_URL を設定してください。',
retryable: false,
},
})
const configFailure = (diagnostic: unknown): LoadResult => {
console.error('Bird client configuration failed:', diagnostic)
return {
ok: false,
error: {
code: 'relay-config',
message: 'TWITTER_RELAY_BASE_URL を設定してください。',
retryable: false,
},
}
}
async function reader() {
const { getBirdReader } = await import('./bird-client.server')
@@ -22,8 +25,8 @@ export const loadUserPosts = createServerFn({ method: 'GET' })
.handler(async ({ data }) => {
try {
return await loadUserPage(await reader(), data)
} catch {
return configFailure()
} catch (error) {
return configFailure(error)
}
})
@@ -32,7 +35,7 @@ export const searchPosts = createServerFn({ method: 'GET' })
.handler(async ({ data }) => {
try {
return await searchPage(await reader(), data)
} catch {
return configFailure()
} catch (error) {
return configFailure(error)
}
})