error handling
This commit is contained in:
parent
aac6c3dd0e
commit
ea26f6a1f5
|
@ -85,21 +85,23 @@ app.controller('MailboxController', ["$scope", "$interval", "$http", "$log", fun
|
||||||
|
|
||||||
self.loadEmailsAsync = function (username) {
|
self.loadEmailsAsync = function (username) {
|
||||||
$log.debug("updating mails for ", username);
|
$log.debug("updating mails for ", username);
|
||||||
self.loadEmails(self.username).then(function (data) {
|
$http.get(backend_url, {params: {username: username, action: "get"}})
|
||||||
self.mails = data.mails;
|
.then(function successCallback(response) {
|
||||||
self.address = data.address;
|
|
||||||
self.username = data.username;
|
|
||||||
$log.debug("received mails for ", username);
|
$log.debug("received mails for ", username);
|
||||||
|
if (response.data.mails) {
|
||||||
|
self.error = null;
|
||||||
|
self.mails = response.data.mails;
|
||||||
|
self.address = response.data.address;
|
||||||
|
self.username = response.data.username;
|
||||||
|
} else {
|
||||||
|
self.error = "There is a problem with fetching the JSON. (JSON_ERROR). Make sure the backend works corrently using the webbrowser developer tools. Reponse:" + response.data;
|
||||||
|
}
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
$log.error(response);
|
||||||
|
self.error = "There is a problem with fetching the JSON. (HTTP_ERROR). Status:" + response.status;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.loadEmails = function (username) {
|
|
||||||
return $http.get(backend_url, {params: {username: username, action: "get"}})
|
|
||||||
.then(function (response) {
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.updateMails()
|
self.updateMails()
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -44,6 +44,12 @@
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="container min-height">
|
<div class="container min-height">
|
||||||
|
|
||||||
|
<div ng-if="$ctrl.error" class="alert alert-danger" role="alert">
|
||||||
|
Opps! {{$ctrl.error}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<p ng-if="!$ctrl.username">
|
<p ng-if="!$ctrl.username">
|
||||||
Use the buttons above to create a new inbox, or open a specific mailbox.
|
Use the buttons above to create a new inbox, or open a specific mailbox.
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user