aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/nbi/exceptions/BackendErrorHandler.java
blob: 34c4ac55d1df22686e3eb8cf598921301100f456 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package org.onap.nbi.exceptions;

import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.ResponseErrorHandler;

import java.io.IOException;

public class BackendErrorHandler implements ResponseErrorHandler {

    private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();

    @Override
    public boolean hasError(ClientHttpResponse response) throws IOException {
        return errorHandler.hasError(response);
    }

    @Override
    public void handleError(ClientHttpResponse response) throws IOException {
        if (response.getStatusCode() != null) {
            throw new BackendFunctionalException(response.getStatusCode(), response.getStatusText());
        }
    }
}