colors
diff --git a/share/tools/web_config/js/app.js b/share/tools/web_config/js/app.js
index 06d386512..296a11c10 100644
--- a/share/tools/web_config/js/app.js
+++ b/share/tools/web_config/js/app.js
@@ -31,3 +31,39 @@ fishconfig.config(
redirectTo: "/colors"
})
}]);
+
+/* Inspired from http://blog.tomaka17.com/2012/12/random-tricks-when-using-angularjs/ */
+fishconfig.config(function($httpProvider, $compileProvider) {
+ var global_error_element = null;
+
+ var showMessage = function(content) {
+ global_error_element.text(content);
+ };
+
+ $httpProvider.responseInterceptors.push(function($q) {
+ return function(promise) {
+ return promise.then(function(successResponse) {
+ showMessage('');
+ return successResponse;
+ }, function(errorResponse) {
+ switch (errorResponse.status) {
+ case 0:
+ showMessage("The request received an error. Perhaps the server has shut down.");
+ break;
+ case 500:
+ showMessage('Server internal error: ' + errorResponse.data);
+ break;
+ default:
+ showMessage('Error ' + errorResponse.status + ': ' + errorResponse.data);
+ }
+ return $q.reject(errorResponse);
+ });
+ };
+ });
+
+ $compileProvider.directive('errorMessage', function() {
+ return {
+ link: function(scope, element, attrs) { global_error_element = element; }
+ };
+ });
+});