@@ -0,0 +1,1285 @@
+package com.orange.ngsi2.client;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.orange.ngsi2.exception.Ngsi2Exception;%0Aimport com.orange.ngsi2.model.Error;%0Aimport org.springframework.http.client.ClientHttpResponse;%0Aimport org.springframework.web.client.ResponseErrorHandler;%0A%0Aimport java.io.IOException;%0A%0A/**%0A * Error responses should contain an Error json structure.%0A * Handle all errors by throwing an Ngsi2Exception containing the error.%0A */%0Aclass Ngsi2ResponseErrorHandler implements ResponseErrorHandler %7B%0A%0A    private ObjectMapper objectMapper;%0A%0A    Ngsi2ResponseErrorHandler(ObjectMapper objectMapper) %7B%0A        this.objectMapper = objectMapper;%0A    %7D%0A%0A    @Override%0A    public boolean hasError(ClientHttpResponse response) throws IOException %7B%0A        return response.getStatusCode().is4xxClientError() %7C%7C response.getStatusCode().is5xxServerError();%0A    %7D%0A%0A    @Override%0A    public void handleError(ClientHttpResponse response) throws IOException %7B%0A        Ngsi2Exception ex;%0A        try %7B%0A            ex =  new Ngsi2Exception(objectMapper.readValue(response.getBody(), Error.class));%0A        %7D catch (Exception e) %7B%0A            ex = new Ngsi2Exception(response.getStatusCode().toString(), response.getStatusText(), null);%0A        %7D%0A        throw ex;%0A    %7D%0A%7D%0A

add a ResponseErrorHandler to handle parsing errors