We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e97cb9d commit d2cf8b6Copy full SHA for d2cf8b6
1 file changed
apps/admin/src/hooks/use-simulate.ts
@@ -46,8 +46,15 @@ export function useCreateSandbox() {
46
body: JSON.stringify(params),
47
})
48
if (!res.ok) {
49
- const data = (await res.json().catch(() => ({ error: 'Request failed' }))) as { error: string }
50
- throw new Error(data.error)
+ const text = await res.text()
+ let msg = `Request failed (${res.status})`
51
+ try {
52
+ const data = JSON.parse(text) as { error?: string }
53
+ if (data.error) msg = data.error
54
+ } catch {
55
+ if (text.length > 0) msg = text.slice(0, 500)
56
+ }
57
+ throw new Error(msg)
58
}
59
return res.json() as Promise<SandboxResult>
60
},
0 commit comments