{"record":{"id":"6c561afbd70469ff","repo":"quarkusio/quarkus","slug":"status-statustext-body","errorCode":null,"errorMessage":"${status} ${statusText}: ${body}","messagePattern":"\\$\\{status\\} \\$\\{statusText\\}: \\$\\{body\\}","errorType":"http","errorClass":"RestError","httpStatus":null,"severity":"error","filePath":"extensions/smallrye-openapi/deployment/src/main/resources/rest/rest-client.js","lineNumber":94,"sourceCode":"                if (value !== undefined && value !== null) {\n                    document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n                }\n            }\n        }\n\n        const token = await this._resolveToken();\n        if (token) {\n            headers['Authorization'] = token;\n        }\n\n        const options = { method, headers };\n        if (body !== null && body !== undefined) {\n            options.body = typeof body === 'string' ? body : JSON.stringify(body);\n        }\n\n        const resp = await fetch(url, options);\n        if (!resp.ok) {\n            throw new RestError(resp.status, resp.statusText, await resp.text().catch(() => ''));\n        }\n        const text = await resp.text();\n        if (!text) {\n            return null;\n        }\n        try {\n            return JSON.parse(text);\n        } catch {\n            return text;\n        }\n    }\n\n    _resolveToken() {\n        const provider = this._tokenProvider || RestClient._config.tokenProvider;\n        if (provider) {\n            return provider();\n        }\n        return this._token || RestClient._config.token || null;","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/smallrye-openapi/deployment/src/main/resources/rest/rest-client.js#L76-L112","documentation":"In the Dev UI-generated REST client JS, every fetch that does not return resp.ok throws a RestError built from the HTTP status, statusText, and response body. This surfaces any non-2xx HTTP response from a REST call made by the Dev UI REST client.","triggerScenarios":"Any REST request made from the Dev UI client that the server answers with a non-2xx status (404 unknown endpoint, 400 bad payload, 401/403 auth failure, 500 server error).","commonSituations":"Calling a wrong or misspelled path; missing auth token/credentials; backend validation failures; server-side exceptions.","solutions":["Read the body in the RestError — it usually contains the server's error explanation","Verify the URL/path, HTTP method, and payload sent to the endpoint","Fix authentication (token expiry, missing credentials) if the status is 401/403","Check server logs for a 500 stack trace and fix the backend"],"exampleFix":"// before\nawait client.get('/api/unknow-endpoint');\n// after\nawait client.get('/api/known-endpoint');\n// and handle failures\ntry { await client.get('/api/known-endpoint'); }\ncatch (e) { console.error(e.status, e.body); }","handlingStrategy":"try-catch","validationCode":"// validate the endpoint before calling\nconst head = await fetch(url, { method: 'HEAD' });\nif (!head.ok) { console.warn('endpoint not ready:', head.status); }","typeGuard":"function isRestError(e) { return e instanceof RestError && typeof e.status === 'number'; }","tryCatchPattern":"try { const data = await client.get(path); } catch (e) { if (e instanceof RestError) { console.error(`HTTP ${e.status}: ${e.body}`); } else { throw e; } }","preventionTips":["Log the RestError body — it contains the server explanation","Check status code first: 4xx = fix request/auth, 5xx = check server logs","Verify the endpoint path and payload against the OpenAPI document in Dev UI"],"tags":["http","rest","devui","javascript"],"backgroundTag":"http-error-response","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}