Skip to main content

HTTP Error Handling

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