frontend: console.log is not a good way to handle errors
This commit is contained in:
parent
07cea2e04a
commit
0414c392bf
2 changed files with 5 additions and 2 deletions
|
@ -221,6 +221,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
|
|
||||||
$scope.hsubmit = function(hint) {
|
$scope.hsubmit = function(hint) {
|
||||||
hint.submitted = true;
|
hint.submitted = true;
|
||||||
|
$scope.hinterror = null;
|
||||||
$http({ url: "/openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).then(function(response, status, header, config) {
|
$http({ url: "/openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).then(function(response, status, header, config) {
|
||||||
var checkDiffHint = function() {
|
var checkDiffHint = function() {
|
||||||
$http.get("/my.json").then(function(response) {
|
$http.get("/my.json").then(function(response) {
|
||||||
|
@ -239,8 +240,8 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
};
|
};
|
||||||
checkDiffHint();
|
checkDiffHint();
|
||||||
}, function(response, status, header, config) {
|
}, function(response, status, header, config) {
|
||||||
|
$scope.hinterror = response.data.errmsg;
|
||||||
hint.submitted = false;
|
hint.submitted = false;
|
||||||
console.error(response.data.errmsg);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
@ -488,7 +489,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
$location.url("/");
|
$location.url("/");
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
$scope.messageClass = {"text-danger": true};
|
$scope.messageClass = {"text-danger": true};
|
||||||
console.log(response);
|
|
||||||
if (response.data && response.data.errmsg)
|
if (response.data && response.data.errmsg)
|
||||||
$scope.message = response.data.errmsg;
|
$scope.message = response.data.errmsg;
|
||||||
else
|
else
|
||||||
|
|
|
@ -56,6 +56,9 @@
|
||||||
<div class="card-header bg-info text-white">
|
<div class="card-header bg-info text-white">
|
||||||
<span class="glyphicon glyphicon-lamp" aria-hidden="true"></span> Indices
|
<span class="glyphicon glyphicon-lamp" aria-hidden="true"></span> Indices
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-body" ng-if="hinterror">
|
||||||
|
<div class="card-text text-danger" ng-bind="hinterror"></div>
|
||||||
|
</div>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<a target="_self" class="list-group-item text-light" ng-repeat="hint in my.exercices[current_exercice].hints" ng-href="{{ hint.file }}">
|
<a target="_self" class="list-group-item text-light" ng-repeat="hint in my.exercices[current_exercice].hints" ng-href="{{ hint.file }}">
|
||||||
<button type="button" ng-click="hsubmit(hint)" class="float-right btn btn-info" ng-if="!(hint.content || hint.file)" ng-class="{disabled: hint.submitted}"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span> Débloquer</button>
|
<button type="button" ng-click="hsubmit(hint)" class="float-right btn btn-info" ng-if="!(hint.content || hint.file)" ng-class="{disabled: hint.submitted}"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span> Débloquer</button>
|
||||||
|
|
Reference in a new issue