Skip to content

Error

A turn that failed, shown inside that turn — what went wrong in words, the technical detail beneath — with whatever had already arrived kept above it.

  • type: 'error'
On this page
Open

When a turn fails (the provider rejects the request, the network drops, a limit is reached), the failure is an error segment in the reply that failed, not a toast somewhere else on the page. The reader sees which question went unanswered.

With AparteClient, you write nothing: a failed turn gets this card, its message from the error, its detail from the error’s code, and the full error still reaches your code on the aparte-message-error event.

Open

The card is added after what had already streamed; the partial reply stays.

aparteGlobalConfig.setErrorRenderer() replaces the card. It receives the message and the detail and returns an element or an HTML string, for a product that adds a “Try again” button or a link to its status page:

ts
import { aparteGlobalConfig } from '@aparte/core';

aparteGlobalConfig.setErrorRenderer(({ message }) => {
  const card = document.createElement('div');
  card.className = 'aparte-alert aparte-alert--danger';
  card.textContent = `${message} — see status.example.com`;
  return card;
});

The built-in card wears the kit’s Alert recipe, so its colours are the alert’s.

AparteErrorSegment, discriminated by type: 'error'.

FieldTypeRequiredDescription
contentstringyes
detailsstring—
stackstring—
  • The card’s heading comes from the error locale key and is translated with the rest of the chat; the message is shown as it arrived, since it is the model’s or the server’s text.
  • The failure is written, not only coloured: a reader who cannot see red still reads “Error”.