Skip to content
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

Extract exception handling to app controller level #645

Open
lauraluiz opened this issue Aug 17, 2017 · 0 comments
Open

Extract exception handling to app controller level #645

lauraluiz opened this issue Aug 17, 2017 · 0 comments
Milestone

Comments

@lauraluiz
Copy link
Contributor

lauraluiz commented Aug 17, 2017

Currently they are being handled all in the handleClientErrorFailedAction, but it would be better to be extracted and handled in the app.

Current:

// SunriseLogInController.java
    @Override
    public CompletionStage<Result> handleClientErrorFailedAction(final Void input, final Form<? extends LogInFormData> form, final ClientErrorException clientErrorException) {
        if (isCustomerInvalidCredentialsError(clientErrorException)) {
            saveFormError(form, "Invalid credentials"); // TODO i18n
            return showFormPageWithErrors(input, form);
        } else {
            return WithContentFormFlow.super.handleClientErrorFailedAction(input, form, clientErrorException);
        }
    }

To be:

// SunriseLogInController.java
    @Override
    public CompletionStage<Result> handleClientErrorFailedAction(final Void input, final Form<? extends LogInFormData> form, final ClientErrorException clientErrorException) {
        if (throwable instanceof ErrorResponseException 
 && isCustomerInvalidCredentialsError(clientErrorException)) {
            return handleCustomerInvalidCredentialsException(form, (ErrorResponseException) throwable);
        } else {
            return WithContentFormFlow.super.handleClientErrorFailedAction(input, form, clientErrorException);
        }
    }

protected abstract CompletionStage<Result> handleCustomerInvalidCredentialsException(final Form<? extends LogInFormData> form, final ErrorResponseException errorResponseException);
@lauraluiz lauraluiz added this to the v1.0.0-RC1 milestone Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant