|
|
|
@ -39,7 +39,7 @@ import org.thingsboard.server.common.data.StringUtils; |
|
|
|
import org.springframework.util.concurrent.ListenableFuture; |
|
|
|
import org.springframework.util.concurrent.ListenableFutureCallback; |
|
|
|
import org.springframework.web.client.AsyncRestTemplate; |
|
|
|
import org.springframework.web.client.HttpClientErrorException; |
|
|
|
import org.springframework.web.client.RestClientResponseException; |
|
|
|
import org.springframework.web.util.UriComponentsBuilder; |
|
|
|
import org.thingsboard.rule.engine.api.TbContext; |
|
|
|
import org.thingsboard.rule.engine.api.TbNodeException; |
|
|
|
@ -261,11 +261,11 @@ public class TbHttpClient { |
|
|
|
private TbMsg processException(TbContext ctx, TbMsg origMsg, Throwable e) { |
|
|
|
TbMsgMetaData metaData = origMsg.getMetaData(); |
|
|
|
metaData.putValue(ERROR, e.getClass() + ": " + e.getMessage()); |
|
|
|
if (e instanceof HttpClientErrorException) { |
|
|
|
HttpClientErrorException httpClientErrorException = (HttpClientErrorException) e; |
|
|
|
metaData.putValue(STATUS, httpClientErrorException.getStatusText()); |
|
|
|
metaData.putValue(STATUS_CODE, httpClientErrorException.getRawStatusCode() + ""); |
|
|
|
metaData.putValue(ERROR_BODY, httpClientErrorException.getResponseBodyAsString()); |
|
|
|
if (e instanceof RestClientResponseException) { |
|
|
|
RestClientResponseException restClientResponseException = (RestClientResponseException) e; |
|
|
|
metaData.putValue(STATUS, restClientResponseException.getStatusText()); |
|
|
|
metaData.putValue(STATUS_CODE, restClientResponseException.getRawStatusCode() + ""); |
|
|
|
metaData.putValue(ERROR_BODY, restClientResponseException.getResponseBodyAsString()); |
|
|
|
} |
|
|
|
return ctx.transformMsg(origMsg, origMsg.getType(), origMsg.getOriginator(), metaData, origMsg.getData()); |
|
|
|
} |
|
|
|
|