quarkusio/quarkus · error · RestError

${status} ${statusText}: ${body}

Error message

${status} ${statusText}: ${body}

What it means

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.

Source

Thrown at extensions/smallrye-openapi/deployment/src/main/resources/rest/rest-client.js:94

                if (value !== undefined && value !== null) {
                    document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
                }
            }
        }

        const token = await this._resolveToken();
        if (token) {
            headers['Authorization'] = token;
        }

        const options = { method, headers };
        if (body !== null && body !== undefined) {
            options.body = typeof body === 'string' ? body : JSON.stringify(body);
        }

        const resp = await fetch(url, options);
        if (!resp.ok) {
            throw new RestError(resp.status, resp.statusText, await resp.text().catch(() => ''));
        }
        const text = await resp.text();
        if (!text) {
            return null;
        }
        try {
            return JSON.parse(text);
        } catch {
            return text;
        }
    }

    _resolveToken() {
        const provider = this._tokenProvider || RestClient._config.tokenProvider;
        if (provider) {
            return provider();
        }
        return this._token || RestClient._config.token || null;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Read the body in the RestError — it usually contains the server's error explanation
  2. Verify the URL/path, HTTP method, and payload sent to the endpoint
  3. Fix authentication (token expiry, missing credentials) if the status is 401/403
  4. Check server logs for a 500 stack trace and fix the backend

Example fix

// before
await client.get('/api/unknow-endpoint');
// after
await client.get('/api/known-endpoint');
// and handle failures
try { await client.get('/api/known-endpoint'); }
catch (e) { console.error(e.status, e.body); }
Defensive patterns

Strategy: try-catch

Validate before calling

// validate the endpoint before calling
const head = await fetch(url, { method: 'HEAD' });
if (!head.ok) { console.warn('endpoint not ready:', head.status); }

Type guard

function isRestError(e) { return e instanceof RestError && typeof e.status === 'number'; }

Try / catch

try { const data = await client.get(path); } catch (e) { if (e instanceof RestError) { console.error(`HTTP ${e.status}: ${e.body}`); } else { throw e; } }

Prevention

When it happens

Trigger: 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).

Common situations: Calling a wrong or misspelled path; missing auth token/credentials; backend validation failures; server-side exceptions.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/6c561afbd70469ff. Report an issue: GitHub.