MindError. Import them and the type guards from @ulesson-education/mind-sdk:
Error types
| Error | Thrown when |
|---|---|
ConfigurationError | authCookieKey is missing or empty, baseUrl is malformed, or the first updateContext lacks a pageType. |
InitializationError | Mounting fails (already mounted, or container not found). |
StateTransitionError | An invalid state transition is attempted. |
ContextError | Context is updated before it is initialized. |
MindApiError | The API returns an error response. |
NetworkError | The HTTP request fails before a response. |
MindApiError helpers
MindApiError carries an HTTP status and code, plus helpers including isAuthError(), isRateLimitError(), isValidationError(), isServerError(), isRetryable(), and getValidationErrors():
Auth failure (401)
When any SDK HTTP request receives a401, the widget hides itself by calling widget.hide() and emits an authFailed event. The SDK does not refresh the session — restoring it is the host app’s job. After the host re-establishes the session cookie, call widget.show() to bring the widget back.