C1Component accepts an onError callback to handle errors that occur during rendering.
Basic Usage
Error Object
TheonError callback receives an object with:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Documentation MCP is live. Click here to integrate into your IDE (Cursor, VSCode, Claude)
Pass custom onError callback to handle application level errors gracefully
C1Component accepts an onError callback to handle errors that occur during rendering.
import { C1Component } from "@thesysai/genui-sdk";
<C1Component
c1Response={c1Response}
onError={({ code, c1Response }) => {
console.error(`C1 Error: ${code}`, c1Response);
}}
/>
onError callback receives an object with:
| Property | Type | Description |
|---|---|---|
code | number | Error code indicating the type of error |
c1Response | string | The response content at the time of error |
import { C1Component } from "@thesysai/genui-sdk";
import { useState } from "react";
function App() {
const [error, setError] = useState<{ code: number; message: string } | null>(null);
if (error) {
return (
<div className="error-state">
Something went wrong (Error {error.code}). Please try again.
</div>
);
}
return (
<C1Component
c1Response={c1Response}
onError={({ code, c1Response }) => {
console.error(`C1 Error: ${code}`, c1Response);
setError({ code, message: c1Response });
}}
/>
);
}
Was this page helpful?