client/api: handle connection errors

This commit is contained in:
rr- 2016-04-02 18:57:17 +02:00
parent 583e73dfc7
commit 60a677edf4
3 changed files with 5 additions and 2 deletions

View file

@ -112,6 +112,7 @@ nav.text-nav ul li.active a {
.messages {
width: 30em;
max-width: 100%;
}
.messages .message {
display: inline-block;

View file

@ -31,7 +31,9 @@ class Api {
req.set('Accept', 'application/json')
.end((error, response) => {
if (error) {
reject(response.body);
reject(response && response.body ? response.body : {
'title': 'Networking error',
'description': error.message});
} else {
resolve(response.body);
}

View file

@ -32,7 +32,7 @@ class BaseView {
const messagesHolder = this.contentHolder.querySelector('.messages');
/* TODO: animate this */
const node = document.createElement('div');
node.innerHTML = message;
node.innerHTML = message.replace(/\n/g, '<br/>');
node.classList.add('message');
node.classList.add(className);
messagesHolder.appendChild(node);