{"record":{"id":"72719b633e75c411","repo":"windmill-labs/windmill","slug":"throw-error-e","errorCode":null,"errorMessage":"throw Error(e)","messagePattern":"throw Error\\(e\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/Dev.svelte","lineNumber":406,"sourceCode":"\n\t\t\t\t\tconst req = await fetch(url, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: form,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tAuthorization: 'Bearer ' + token\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\tif (req.status != 201) {\n\t\t\t\t\t\tthrow Error(\n\t\t\t\t\t\t\t`Script snapshot creation was not successful: ${req.status} - ${\n\t\t\t\t\t\t\t\treq.statusText\n\t\t\t\t\t\t\t} - ${await req.text()}`\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn await req.text()\n\t\t\t\t} catch (e) {\n\t\t\t\t\tsendUserToast(`Failed to send bundle ${e}`, true)\n\t\t\t\t\tthrow Error(e)\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tdone(x) {\n\t\t\t\t\tloadPastTests()\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\t\tloadingCodebaseButton = false\n\t}\n\tconst onPopState = () => {\n\t\twatchPath = parseWatchPath()?.replace(PATH_SUFFIX_RE, '')\n\t\tif (watchPath && socket && socket.readyState === WebSocket.OPEN) {\n\t\t\tsocket.send(JSON.stringify({ type: 'loadWmPath', path: watchPath }))\n\t\t}\n\t}\n\n\tonMount(() => {","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/Dev.svelte#L388-L424","documentation":"Catch-all rethrow in `testBundle`: when sending the test bundle fails for any reason (including the snapshot error above), a toast is shown and the original error is wrapped with `throw Error(e)`. The resulting message is just the stringified original error, so the real cause is inside it.","triggerScenarios":"Any failure inside the bundle-send pipeline: snapshot upload error (1333), network interruption, token missing, or an exception while building the form payload.","commonSituations":"Expired auth token mid-session, backend restart during a test run, offline dev environment, or a snapshot upload failure being double-wrapped.","solutions":["Look at the toast / inner message: it is the original error stringified — fix that root cause","Handle 401 by re-authenticating before re-running the test","Check backend connectivity and that the script exists","Catch this in the test runner and retry transient network failures"],"exampleFix":"// before\ntry { await testBundle() } catch (e) { console.error(e) }\n// after\ntry { await testBundle() } catch (e) {\n  if (String(e).includes('401')) { await relogin(); await testBundle(); }\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await testBundle() } catch (e) {\n  const msg = String(e);\n  if (msg.includes('401')) { await relogin(); await testBundle(); }\n  else if (/Failed to send bundle/.test(msg)) console.error('Bundle send root cause:', msg);\n  else throw e;\n}","preventionTips":["Read the stringified inner error — it carries the real cause","Fix the underlying snapshot (1333) or network issue rather than retrying blindly","Monitor backend uptime during dev test runs"],"tags":["dev-tools","error-handling","network"],"backgroundTag":"wrapped-error-rethrow","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}