summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/nbi/exceptions/BackendErrorHandler.java
blob: 7c28b058454ab0df947c16c807c0848983ddb537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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());
        }
    }
}