fix(ui): extract meaningful error messages from API responses
All checks were successful
CI / build (push) Successful in 2m9s
CI / docker (push) Successful in 1m28s

Introduces ApiError class in client.ts that parses Spring Boot error
bodies to extract human-readable messages (message, error, detail fields).
Adds errorMessage() helper used by all toast descriptions instead of
raw String(err) which dumped JSON blobs to the user.

Affected: all 10 page components that display error toasts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-26 21:10:28 +02:00
parent 73e41e5607
commit 088bc34e67
11 changed files with 95 additions and 40 deletions

View File

@@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from 'react';
import { useLogto } from '@logto/react';
import { Card, Input, Button, FormField, Alert } from '@cameleer/design-system';
import cameleerLogo from '@cameleer/design-system/assets/cameleer-logo.svg';
import { api } from '../api/client';
import { api, errorMessage } from '../api/client';
import { toSlug } from '../utils/slug';
import styles from './OnboardingPage.module.css';
@@ -56,7 +56,7 @@ export function OnboardingPage() {
// auto-approves and redirects back with fresh tokens.
await signIn(`${window.location.origin}/platform/callback`);
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
const msg = err instanceof Error ? err.message : errorMessage(err);
if (msg.includes('409')) {
setError('This organization name is already taken. Try a different organization name.');
} else {