aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/ServerPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/settings/ServerPage.js')
-rw-r--r--modern/src/settings/ServerPage.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/modern/src/settings/ServerPage.js b/modern/src/settings/ServerPage.js
index 5fdba47b..b745cb96 100644
--- a/modern/src/settings/ServerPage.js
+++ b/modern/src/settings/ServerPage.js
@@ -15,6 +15,7 @@ import PageLayout from '../common/components/PageLayout';
import SettingsMenu from './components/SettingsMenu';
import useCommonDeviceAttributes from '../common/attributes/useCommonDeviceAttributes';
import useCommonUserAttributes from '../common/attributes/useCommonUserAttributes';
+import { useCatch } from '../reactHelper';
const useStyles = makeStyles((theme) => ({
container: {
@@ -44,7 +45,7 @@ const ServerPage = () => {
const original = useSelector((state) => state.session.server);
const [item, setItem] = useState({ ...original });
- const handleSave = async () => {
+ const handleSave = useCatch(async () => {
const response = await fetch('/api/server', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
@@ -54,8 +55,10 @@ const ServerPage = () => {
if (response.ok) {
dispatch(sessionActions.updateServer(await response.json()));
history.goBack();
+ } else {
+ throw Error(await response.text());
}
- };
+ });
return (
<PageLayout menu={<SettingsMenu />} breadcrumbs={['settingsTitle', 'settingsServer']}>