diff --git a/src/common/ErrorHandler.js b/src/common/ErrorHandler.js
new file mode 100644
index 00000000..ec069b2f
--- /dev/null
+++ b/src/common/ErrorHandler.js
@@ -0,0 +1,37 @@
+import React from 'react';
+import * as PropTypes from 'prop-types';
+import './ErrorHandler.scss';
+import { Button } from 'reactstrap';
+
+const ErrorHandler = ({ location }) => class ErrorHandler extends React.Component {
+ static propTypes = {
+ children: PropTypes.node.isRequired,
+ };
+
+ constructor(props) {
+ super(props);
+ this.state = { hasError: false };
+ }
+
+ static getDerivedStateFromError() {
+ // Update state so the next render will show the fallback UI.
+ return { hasError: true };
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return (
+
+
Oops! This is awkward :S
+
It seems that something went wrong. Try refreshing the page or just click this button.
+
+
+
+ );
+ }
+
+ return this.props.children;
+ }
+};
+
+export default ErrorHandler;
diff --git a/src/common/ErrorHandler.scss b/src/common/ErrorHandler.scss
new file mode 100644
index 00000000..0c757135
--- /dev/null
+++ b/src/common/ErrorHandler.scss
@@ -0,0 +1,9 @@
+@import '../utils/mixins/vertical-align.scss';
+
+.error-handler {
+ @include vertical-align();
+
+ padding: 20px;
+ text-align: center;
+ width: 100%;
+}
diff --git a/src/common/services/provideServices.js b/src/common/services/provideServices.js
index eb7e0c9d..6fcc775b 100644
--- a/src/common/services/provideServices.js
+++ b/src/common/services/provideServices.js
@@ -3,6 +3,7 @@ import MainHeader from '../MainHeader';
import Home from '../Home';
import MenuLayout from '../MenuLayout';
import AsideMenu from '../AsideMenu';
+import ErrorHandler from '../ErrorHandler';
const provideServices = (bottle, connect, withRouter) => {
bottle.constant('window', global.window);
@@ -29,6 +30,8 @@ const provideServices = (bottle, connect, withRouter) => {
bottle.decorator('MenuLayout', withRouter);
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
+
+ bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window');
};
export default provideServices;
diff --git a/src/index.js b/src/index.js
index c875ae06..5b6446f9 100644
--- a/src/index.js
+++ b/src/index.js
@@ -16,14 +16,16 @@ import './index.scss';
// This overwrites icons used for leaflet maps, fixing some issues caused by webpack while processing the CSS
fixLeafletIcons();
-const { App, ScrollToTop } = container;
+const { App, ScrollToTop, ErrorHandler } = container;
render(
-
-
-
+
+
+
+
+
,
document.getElementById('root')