mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2025-05-17 11:58:06 +08:00
Refactored error handling in API functions and improved error feedback in pages
This commit is contained in:
parent
c4c11d1afe
commit
cfd82d3c42
10 changed files with 181 additions and 116 deletions
|
@ -108,7 +108,7 @@ export default function Home() {
|
|||
queryFn: async () => {
|
||||
const data = await GetStudentStatus();
|
||||
if (data[0] == false) {
|
||||
return Promise.reject(new Error());
|
||||
return Promise.reject(new Error(JSON.stringify(data[1])));
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
@ -126,8 +126,13 @@ export default function Home() {
|
|||
}
|
||||
console.log(data[1]);
|
||||
},
|
||||
onError: () => {
|
||||
setFeedback("Unable to query available subjects");
|
||||
onError: (error: Error) => {
|
||||
toast.show(String(error), {
|
||||
type: "warning",
|
||||
placement: "top",
|
||||
duration: 2000,
|
||||
animationType: "slide-in",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -149,8 +154,8 @@ export default function Home() {
|
|||
animationType: "slide-in",
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
toast.show("Server error. Unable to update student status", {
|
||||
onError: (error: Error) => {
|
||||
toast.show(String(error), {
|
||||
type: "warning",
|
||||
placement: "top",
|
||||
duration: 2000,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue