forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp.js
31 lines (27 loc) · 801 Bytes
/
http.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
module.exports = [
"$httpProvider",
"$provide",
function ($httpProvider, $provide) {
$provide.factory("handleServerNotReachable", [
"$q",
"$injector",
function ($q, $injector) {
return {
responseError: function (rejection) {
var Notification = $injector.get("Notification");
if (rejection.status === -1) {
Notification.error({
title: "APP.GLOBAL.NOTIFICATION.HEADER.CONNECTION_ISSUE",
message: "APP.GLOBAL.NOTIFICATION.MESSAGE.SERVER_NOT_REACHABLE",
delay: 10000,
});
}
return $q.reject(rejection);
},
};
},
]);
$httpProvider.interceptors.push("handleServerNotReachable");
},
];