Show toast and stringified error on profiles fetch failure
cgen-7f480f77a3014ba1be8c82e313219e3c
This commit is contained in:
parent
ef332d2b76
commit
9d9c37d59b
1 changed files with 13 additions and 1 deletions
|
|
@ -316,13 +316,25 @@ const DevelopersDirectory = () => {
|
|||
});
|
||||
}, [profiles, search, realmFilter]);
|
||||
|
||||
const { toast } = useToast();
|
||||
|
||||
const refreshProfiles = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const list = await aethexUserService.listProfiles(60);
|
||||
setProfiles(list);
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Failed to load profiles", error);
|
||||
const msg =
|
||||
(typeof error === "string" && error) ||
|
||||
error?.message ||
|
||||
JSON.stringify(error, Object.getOwnPropertyNames(error)) ||
|
||||
"Unknown error";
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Failed to load profiles",
|
||||
description: msg,
|
||||
});
|
||||
setProfiles([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue