forked from trent_larson/crowd-funder-for-time-pwa
Added error handling and new alerts in DiscoverView
This commit is contained in:
@@ -182,4 +182,14 @@ const router = createRouter({
|
|||||||
routes,
|
routes,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const errorHandler = (error, to, from) => {
|
||||||
|
// Handle the error here
|
||||||
|
console.error(error, to, from);
|
||||||
|
console.log("XXXXX");
|
||||||
|
|
||||||
|
// You can also perform additional actions, such as displaying an error message or redirecting the user to a specific page
|
||||||
|
};
|
||||||
|
|
||||||
|
router.onError(errorHandler); // Assign the error handler to the router instance
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -186,6 +186,16 @@ export default class DiscoverView extends Vue {
|
|||||||
|
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
const details = await response.text();
|
const details = await response.text();
|
||||||
|
this.$notify(
|
||||||
|
{
|
||||||
|
group: "alert",
|
||||||
|
type: "danger",
|
||||||
|
title: "Danger Alert",
|
||||||
|
text: details,
|
||||||
|
},
|
||||||
|
-1,
|
||||||
|
);
|
||||||
|
|
||||||
throw details;
|
throw details;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +250,16 @@ export default class DiscoverView extends Vue {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
|
const details = await response.text();
|
||||||
|
this.$notify(
|
||||||
|
{
|
||||||
|
group: "alert",
|
||||||
|
type: "danger",
|
||||||
|
title: "Danger Alert",
|
||||||
|
text: details,
|
||||||
|
},
|
||||||
|
-1,
|
||||||
|
);
|
||||||
throw await response.text();
|
throw await response.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user