Skip to content

Injected Error handler in API responses #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

vivonk
Copy link
Collaborator

@vivonk vivonk commented Mar 26, 2018

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):

error-handler

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests pass.

Signed-off-by: Nirmal Sarswat [email protected]

@vivonk
Copy link
Collaborator Author

vivonk commented Mar 26, 2018

@agentmilindu @malithsen @rajikaimal @JaDogg @rehrumesh please review this one

@agentmilindu agentmilindu changed the base branch from master to develop October 7, 2018 18:17
@agentmilindu
Copy link
Collaborator

@vivonk Can you resolve the conflicts?

@vivonk
Copy link
Collaborator Author

vivonk commented Oct 9, 2018

@agentmilindu done

@vivonk vivonk added enhancement NEXT Next tag describes that this issues have to be resolved asap labels Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement NEXT Next tag describes that this issues have to be resolved asap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants