I having written an error handling function that displays a Modal when some error(Catch) occurs. The following is its implementation:
function displayErrorModal(error){
$scope.error = error;
$scope.modalInstance = $uibModal.open({
templateUrl: '/popeye-application/components/dashboard/dashboard-error-handler.template.jsp',
size: 'lg',
scope: $scope,
backdrop: 'static'
});
}
Whenever there is an error, I call this an handle the error. Following is one such scenario:
function getProductName (name) {
Service.getProductNameByProductID(
filter(name)
).then(function (response) {
// Happy case
}).catch(function (error) {
displayErrorModal(error);
});
}
However, I am not able to handle any 401 Error(Session Expired) using this. How can I handle 401 Errors in AngularJS? Thanks in advance.