Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
fix reqerr log msg
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Jul 14, 2021
1 parent 8b11850 commit 9808bd0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions static/files/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
/* globals app,window */

app.factory("reqerr", function ($rootScope) {
app.factory("reqerr", function ($rootScope, $log) {
return function (xhr) {
if ("data" in xhr) {
$rootScope.err = `${xhr.status} - ${xhr.statusText}`
if ("error" in xhr.data) {
$rootScope.err += ` :${xhr.data.error}`;
switch (typeof xhr.data) {
case "string":
$rootScope.err += ` :${xhr.data}`;
break;
case "object":
if ("error" in xhr.data) {
$rootScope.err += ` :${xhr.data.error}`;
} else {
$rootScope.err += JSON.stringify(xhr.data);
}
break
}
$log.error(xhr.data);
$rootScope.$applyAsync();
Expand Down

0 comments on commit 9808bd0

Please sign in to comment.