Skip to content
EspañolEnglish
All components (283)

Stack trace

AI · StackTrace

What it is and when to use it

A stack trace to read: the error message, its frames with the function and the location, and those of dependencies set aside behind a button.

When to use it

  • Showing a code error to whoever debugs it: from an agent, a test or a service.
  • stack is the text as the engine gives it (V8, Firefox and Safari). With onOpenFrame, the location of each own frame is a button to open the file.
  • Frames from node_modules and from the engine are set aside and shown with a button.

When not to

  • An error message for the end user: Alert.
  • A fragment of code: CodeBlock.
  • The log of a run: ActivityLog.

Keyboard: the title folds and opens; Tab goes through the copy button, the frames that can be opened and the one that shows the internal ones.

Accessibility: the frames are a list; the internal ones are told apart by tone and by being set aside. Copying says so with text in a live region.

Fine-tuning: amset-stacktrace and the amset-stacktrace__* classes.

What it looks like

  1. sendReminderlikely origin/app/src/reminders.ts:42:18
  2. processInvoice/app/src/invoices.ts:118:5

<StackTrace stack={error.stack} defaultExpanded />

Props

Import it with import { StackTrace } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
stackrequiredstringThe trace as the engine gives it: the error message and its frames below.
classNamestringMerged with the library classes; it does not replace them.
defaultExpandedbooleanOpen at the start. Yes by default: whoever looks at a trace comes to read it.
onOpenFrame(frame: StackFrame) => voidIf given, the location of each own frame is a button that calls this (open the file in the editor).

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

In the test bench

Every state and variant, to try one at a time, on its page at storybook.amsetui.com: