You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
![]()
3 years ago
|
angular.module('errors', ['ngResource']).
|
||
|
factory('Errors', function ($resource) {
|
||
|
return $resource('errors', {}, {
|
||
|
kill: { url: 'errors/kill' },
|
||
|
throw: { url: 'errors/throw' }
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function ErrorsController($scope, Errors, Status) {
|
||
|
$scope.kill = function() {
|
||
|
Errors.kill({},
|
||
|
function () {
|
||
|
Status.error("The application should have been killed, but returned successfully instead.");
|
||
|
},
|
||
|
function (result) {
|
||
|
if (result.status === 502)
|
||
|
Status.error("An error occurred as expected, the application backend was killed: " + result.status);
|
||
|
else
|
||
|
Status.error("An unexpected error occurred: " + result.status);
|
||
|
}
|
||
|
);
|
||
|
};
|
||
|
|
||
|
$scope.throwException = function() {
|
||
|
Errors.throw({},
|
||
|
function () {
|
||
|
Status.error("An exception should have been thrown, but was not.");
|
||
|
},
|
||
|
function (result) {
|
||
|
if (result.status === 500)
|
||
|
Status.error("An error occurred as expected: " + result.status);
|
||
|
else
|
||
|
Status.error("An unexpected error occurred: " + result.status);
|
||
|
}
|
||
|
);
|
||
|
};
|
||
|
}
|