Skip to main content

HTTP Error

Subscribe to onSseError to react to HTTP failures returned from the bot provider. Combine with the isHttpError helper from @asgard-js/core to safely inspect the status code.

HTTP 429 Rate Limit

Click the button below to simulate onSseError receiving an HTTP 429. The handler calls isHttpError() to detect the error type, then shows a toast notification. The code block below shows the actual wiring.

Code Example​

import { isHttpError } from "@asgard-js/core";

<Chatbot
onSseError={(error) => {
if (isHttpError(error) && error.status === 429) {
toast.warning("Rate limit reached, please try again later");
}
}}
{...rest}
/>;

HttpError​

PropertyTypeDescription
statusnumberHTTP status code (e.g. 401, 403, 429, 500)
statusTextstringStatus text
bodyunknownResponse body

isHttpError(error) is a type guard — use it before accessing the properties above.

Common Error Codes​

StatusScenario
401Invalid or expired API key
403Not authorized to access this bot provider
429Rate limit exceeded
500Bot provider internal error

The Error Bubble and Its Details Toggle​

An asgard.run.error leaves an error bubble in the thread. It renders the backend's message verbatim — when a sandbox is refused over quota or subscription state, that reason lives only there, and swapping in a fixed string would throw away the user's one clue. "Unexpected error" is the fallback for an event that carries no message at all.

Everything that is diagnostics rather than instruction (code, traceId, the upstream inner) hides behind a Show more / Show less toggle, dumped whole as JSON.stringify({ traceId, ...error }):

  • Dumping it whole is deliberate. This payload's shape is still moving (the backend is filling in code / inner as it goes), so a hand-picked field list would silently omit whatever it adds next; the whole blob also gives an engineer one thing to paste into a ticket.
  • The toggle appears only when there genuinely is something beyond message — otherwise expanding it would reveal the summary already on screen.
  • Backend errors can be arbitrarily long, so the summary clamps to two lines and every expanded region scrolls inside its own height cap; the bubble's footprint stays bounded.

errorMessageRenderer still wins: return a node and it replaces the whole bubble; return null / undefined and it falls through to the default UI rather than blanking it.

The expanded region's colors are overridable — see the JSON and error-detail variables.

Further Reading​

For the underlying message API and error responses, see the Asgard developer docs: