Skip to content

Commit

Permalink
fix: toast error doesn't tell you what the error is (#7601)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
thomasheartman authored Jul 16, 2024
1 parent 248f879 commit cfd2070
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cfd2070

Please sign in to comment.