corr add group
This commit is contained in:
parent
2f1c7bacf4
commit
faf6397f30
@ -207,11 +207,25 @@ export async function POST(req: Request) {
|
||||
// Try to get error details from Keycloak
|
||||
let errorMessage = 'Échec de la création du groupe';
|
||||
try {
|
||||
const errorData = await response.json();
|
||||
// Keycloak error format: { errorMessage: "..." } or { error: "..." }
|
||||
errorMessage = errorData.errorMessage || errorData.error || errorData.message || errorMessage;
|
||||
} catch {
|
||||
// If response is not JSON, use status text
|
||||
// Read response as text first (can only read body once)
|
||||
const text = await response.text();
|
||||
|
||||
if (text.trim()) {
|
||||
// Try to parse as JSON
|
||||
try {
|
||||
const errorData = JSON.parse(text);
|
||||
// Keycloak error format: { errorMessage: "..." } or { error: "..." }
|
||||
errorMessage = errorData.errorMessage || errorData.error || errorData.message || errorMessage;
|
||||
} catch {
|
||||
// If not JSON, use the text as error message
|
||||
errorMessage = text;
|
||||
}
|
||||
} else {
|
||||
// Empty response, use status text
|
||||
errorMessage = response.statusText || errorMessage;
|
||||
}
|
||||
} catch (readError) {
|
||||
// If reading response fails, use status text
|
||||
errorMessage = response.statusText || errorMessage;
|
||||
}
|
||||
|
||||
|
||||
@ -495,10 +495,24 @@ export default function EquipePage() {
|
||||
// Try to parse error message from response
|
||||
let errorMessage = "Échec de la création du groupe";
|
||||
try {
|
||||
const errorData = await response.json();
|
||||
errorMessage = errorData.message || errorData.error || errorMessage;
|
||||
} catch {
|
||||
// If response is not JSON, use status text
|
||||
// Read response as text first (can only read body once)
|
||||
const text = await response.text();
|
||||
|
||||
if (text.trim()) {
|
||||
// Try to parse as JSON
|
||||
try {
|
||||
const errorData = JSON.parse(text);
|
||||
errorMessage = errorData.message || errorData.error || errorMessage;
|
||||
} catch {
|
||||
// If not JSON, use the text as error message
|
||||
errorMessage = text;
|
||||
}
|
||||
} else {
|
||||
// Empty response, use status text
|
||||
errorMessage = response.statusText || errorMessage;
|
||||
}
|
||||
} catch (readError) {
|
||||
// If reading response fails, use status text
|
||||
errorMessage = response.statusText || errorMessage;
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user