diff options
Diffstat (limited to 'js/build/app.js')
-rw-r--r-- | js/build/app.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/build/app.js b/js/build/app.js index e85814e71..f95d582c1 100644 --- a/js/build/app.js +++ b/js/build/app.js @@ -42,7 +42,38 @@ app.config(["$routeProvider", "$provide", "$httpProvider", function ($routeProvi } }; }]); + $provide.factory('ConnectionErrorInterceptor', ["$q", "$timeout", function ($q, $timeout) { + var timer; + return { + responseError: function (response) { + var messages = { + 0: t('news', 'Request failed, network connection ' + + 'unavailable!'), + 401: t('news', 'Request unauthorized. Are you logged in?'), + 403: t('news', 'Request forbidden. Are you an admin?'), + 412: t('news', 'Token expired or app not enabled! ' + + 'Try to reload the page!'), + 500: t('news', 'Internal server error! Please check your ' + + 'data/owncloud.log file for additional ' + + 'information!') + }; + // status 0 is a network error + if (response.status in messages) { + if (timer) { + $timeout.cancel(timer); + } + OC.Notification.hide(); + OC.Notification.showHtml(messages[response.status]); + timer = $timeout(function () { + OC.Notification.hide(); + }, 5000); + } + return $q.reject(response); + } + }; + }]); $httpProvider.interceptors.push('CSRFInterceptor'); + $httpProvider.interceptors.push('ConnectionErrorInterceptor'); // routing var getItemResolve = function (type) { |