Skip to content

Commit

Permalink
circulation_ui: add error logs for item API
Browse files Browse the repository at this point in the history
* Adds invenio logger message.
* Fixes user message in circulation UI.

Co-Authored-by: Renaud Michotte <[email protected]>
  • Loading branch information
zannkukai committed Sep 4, 2019
1 parent a9ed720 commit fd644ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rero_ils/modules/items/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from functools import wraps

from flask import Blueprint, abort, jsonify
from flask import Blueprint, abort, current_app, jsonify
from flask import request as flask_request
from flask_login import current_user
from invenio_circulation.api import get_loan_for_item
Expand Down Expand Up @@ -65,6 +65,7 @@ def decorated_view(*args, **kwargs):
raise(e)
except Exception as e:
# raise(e)
current_app.logger.error(str(e))
return jsonify({'status': 'error: {error}'.format(error=e)}), 500
return decorated_view

Expand Down Expand Up @@ -100,6 +101,7 @@ def decorated_view(*args, **kwargs):
raise(e)
except Exception as e:
# raise(e)
current_app.logger.error(str(e))
return jsonify({'status': 'error: {error}'.format(error=e)}), 500
return decorated_view

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,16 @@ export class MainCheckinCheckoutComponent implements OnInit, NoPendingChange {
return item;
}).filter(item => item.status === ItemStatus.ON_LOAN);
},
(err) => this.toastService.error(
_('an error occurs on the server: ') + err,
_('checkin')
)
(err) => {
let errorMessage = '';
if (err && err.error && err.error.status) {
errorMessage = err.error.status;
}
this.toastService.error(
_('an error occurs on the server: ') + errorMessage,
_('checkin')
);
}
);
}

Expand Down

0 comments on commit fd644ea

Please sign in to comment.