All API errors should have the same structure which is represented by the interface HttpErrorResponse
export interface HttpErrorResponse {
message: string;
status: number;
errors?: Map<string, string>;
generalErrors?: string[];
}
This means it's easier to come up with one solution to handle all errors.
There is a component called ErrorFeedback to which you can pass any errors and it will show them in a nice way, if you pass empty object or without errors it just won't show
Take a look at this example:
const { data, error, isLoading, mutate } = useSWR<
PagedResponse<OrganizationInvite>,
HttpErrorResponse
>("/organizations/invites", () => {
return httpClient.get("/api/organizations/invites", {params: {page}}).then((res) => res.data);
});
...
<InvitesTable data={data} />
<ErrorFeedback errors={error} />