Files
teaching-feedback-assistant/pages/feedback/voice-actions.ts
2026-07-22 15:35:48 +08:00

19 lines
387 B
TypeScript

export async function runWithSessionRefresh<T>(
action: () => Promise<T>,
refreshSession: () => Promise<void>
): Promise<T> {
let result: T
try {
result = await action()
} catch (error) {
try {
await refreshSession()
} catch {
// Preserve the actionable API error and its request ID.
}
throw error
}
await refreshSession()
return result
}