How to handle error code from an http request

0

Below is a method that I use to do some validation, but so far I have not been able to retrieve the request response code. I need to say that when the server response code is 403 show that the user is not allowed to access.

@Target({TYPE})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {CheckValorValidator.class})
public @interface CheckValor{

    String message() default "Mensagem de erro aqui";

    Class<?>[] groups() default {};

    Class<? extends Payload> [] payload() default {};
}

public static class CheckValorValidator implements ConstraintValidator<CheckValor, BigDecimal>{

    @Override
        public void initialize(final CheckPermissao annotation){
    }

    @Override
    public boolean isValid(final BigDecimal valor, final ConstraintValidatorContext context) {
        ex: if 403 mostrar que o usuário não tem permissão
    }
}

Or if you have another more effective way of dealing with this problem.

    
asked by anonymous 12.04.2018 / 19:27

0 answers