Injected Error handler in API responses
Description
Right now, the error handlers were not added to the responses of API. Any HTTP status apart from 200 is not to the worth so, for any other response code, we can show the dialog box that server has gone away or something similar.
Code snippet
This simple code has been used around API responses
if(response.status === 403){
var confirm = $mdDialog.confirm()
.title('Session expires')
.textContent('This is session expire, please login back to continue')
.ariaLabel('403 Alert')
.ok('Take me to Login')
.cancel('Stay here');
$mdDialog.show(confirm).then(function() {
location.href = "/#!/login";
}, function() {
// nothing to do with Stay here
});
return ;
}else if(response.status !== 200){
$mdDialog.show(
$mdDialog.alert()
.clickOutsideToClose(true)
.title('Server has gone away')
.textContent('There is something wrong with the server, please check the errors in log files')
.ariaLabel('Server Disconnect Alert')
.ok('Got it!')
);
return ;
}
Related Issue
#351
How Has This Been Tested?
I tested it by manually switching the server down and on the server down, it shows the pop-up. I tried without authentication and it was catching 403 error perfectly, showing a pop-up to login back.
Screenshots (In case of UI changes):

Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] All new and existing tests pass.
Signed-off-by: Nirmal Sarswat [email protected]
@agentmilindu @malithsen @rajikaimal @JaDogg @rehrumesh please review this one
@vivonk Can you resolve the conflicts?
@agentmilindu done