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
|
// Try to get error details from Keycloak
|
||||||
let errorMessage = 'Échec de la création du groupe';
|
let errorMessage = 'Échec de la création du groupe';
|
||||||
try {
|
try {
|
||||||
const errorData = await response.json();
|
// 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: "..." }
|
// Keycloak error format: { errorMessage: "..." } or { error: "..." }
|
||||||
errorMessage = errorData.errorMessage || errorData.error || errorData.message || errorMessage;
|
errorMessage = errorData.errorMessage || errorData.error || errorData.message || errorMessage;
|
||||||
} catch {
|
} catch {
|
||||||
// If response is not JSON, use status text
|
// 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;
|
errorMessage = response.statusText || errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -495,10 +495,24 @@ export default function EquipePage() {
|
|||||||
// Try to parse error message from response
|
// Try to parse error message from response
|
||||||
let errorMessage = "Échec de la création du groupe";
|
let errorMessage = "Échec de la création du groupe";
|
||||||
try {
|
try {
|
||||||
const errorData = await response.json();
|
// 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;
|
errorMessage = errorData.message || errorData.error || errorMessage;
|
||||||
} catch {
|
} catch {
|
||||||
// If response is not JSON, use status text
|
// 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;
|
errorMessage = response.statusText || errorMessage;
|
||||||
}
|
}
|
||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user