1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: toast error doesn't tell you what the error is (#7601)

This change improves the toast error message for auth settings by
preferring the message from the error's details list if it exists. If
it doesn't it'll still fall back to the original error message.

Before:

![image](https://github.com/user-attachments/assets/6ecb425c-7d6d-4cb9-844e-c7c2ff7088b2)

After:

![image](https://github.com/user-attachments/assets/87d827a8-7f52-40c1-a2c6-ca2d1d3abfb4)
This commit is contained in:
Thomas Heartman 2024-07-16 15:10:44 +02:00 committed by GitHub
parent 248f879553
commit cfd20703b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,8 +12,9 @@ export const handleBadRequest = async (
if (!setErrors) return;
if (res) {
const data = await res.json();
setErrors({ message: data.message });
throw new Error(data.message);
const message = data.details?.[0]?.message ?? data.message;
setErrors({ message });
throw new Error(message);
}
throw new Error();