mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 05:02:42 +00:00
Fix error messages crashing page
This commit is contained in:
@@ -53,7 +53,7 @@ const NotificationAdd = ()=>{
|
|||||||
setNotificationResult('Notification successfully created.');
|
setNotificationResult('Notification successfully created.');
|
||||||
setSearching(false);
|
setSearching(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(error.response.body.message);
|
console.log(err.response.body.message);
|
||||||
setError(`Error saving notification: ${err.response.body.message}`);
|
setError(`Error saving notification: ${err.response.body.message}`);
|
||||||
setSearching(false);
|
setSearching(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ NotificationSchema.statics.addNotification = async function(data) {
|
|||||||
const savedNotification = await newNotification.save();
|
const savedNotification = await newNotification.save();
|
||||||
return savedNotification;
|
return savedNotification;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { message: err.message || 'Error saving notification' };
|
throw { message: err.message || 'Error saving notification' };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,20 +37,20 @@ NotificationSchema.statics.deleteNotification = async function(dismissKey) {
|
|||||||
try {
|
try {
|
||||||
const deletedNotification = await this.findOneAndDelete({ dismissKey }).exec();
|
const deletedNotification = await this.findOneAndDelete({ dismissKey }).exec();
|
||||||
if(!deletedNotification) {
|
if(!deletedNotification) {
|
||||||
return { message: 'Notification not found' };
|
throw { message: 'Notification not found' };
|
||||||
}
|
}
|
||||||
return { message: 'Notification deleted successfully' };
|
return deletedNotification;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { message: err.message || 'Error deleting notification' };
|
throw { message: err.message || 'Error deleting notification' };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationSchema.statics.getAll = async function() {
|
NotificationSchema.statics.getAll = async function() {
|
||||||
try {
|
try {
|
||||||
const notifications = await this.find().exec();
|
const notifications = await this.find().exec();
|
||||||
return { notifications };
|
return notifications;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { message: err.message || 'Error retrieving notifications' };
|
throw { message: err.message || 'Error retrieving notifications' };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user