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

Commit

Permalink
fix: reqerr shows nothing on network layer error
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Jul 21, 2021
1 parent 58f4516 commit 1cc6068
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion static/files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h2>
</div>
<div>
<span>Up {{ ago([[.Uptime]]*1000) }}</span>
<span ng-if="numKeys(state.Users) > 1">,{{ numKeys(state.Users) }} users connected</span>
<span ng-if="numKeys(state.Users) > 1">, {{ numKeys(state.Users) }} users connected</span>
</div>
</footer>
<div ng-if="$root.showEnineStatus" class="ui attached mini message">
Expand Down
14 changes: 8 additions & 6 deletions static/files/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

app.factory("reqerr", function ($rootScope, $log) {
return function (xhr) {
if ("data" in xhr) {
$rootScope.err = `${xhr.status} - ${xhr.statusText}`
$rootScope.err = `${xhr.xhrStatus}: ${xhr.statusText}/${xhr.status}`
if (!xhr.data) {
// data is null, xhr error
$log.error(JSON.stringify(xhr));
} else {
switch (typeof xhr.data) {
case "string":
$rootScope.err += ` :${xhr.data}`;
Expand All @@ -12,13 +15,12 @@ app.factory("reqerr", function ($rootScope, $log) {
if ("error" in xhr.data) {
$rootScope.err += ` :${xhr.data.error}`;
} else {
$rootScope.err += JSON.stringify(xhr.data);
$rootScope.err += JSON.stringify(xhr);
}
break
break;
}
$log.error(xhr.data);
$rootScope.$applyAsync();
}
$rootScope.$applyAsync();
return xhr;
};
});
Expand Down

0 comments on commit 1cc6068

Please sign in to comment.