Skip to content

Commit

Permalink
feat: extend logging for better analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
mebo4b committed Apr 23, 2021
1 parent 00df274 commit faadc60
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import de.caritas.cob.messageservice.api.exception.NoMasterKeyException;
import de.caritas.cob.messageservice.api.exception.RocketChatBadRequestException;
import de.caritas.cob.messageservice.api.exception.RocketChatUserNotInitializedException;
import de.caritas.cob.messageservice.api.helper.XssProtection;
import de.caritas.cob.messageservice.api.helper.JSONHelper;
import de.caritas.cob.messageservice.api.helper.XssProtection;
import de.caritas.cob.messageservice.api.model.AliasMessageDTO;
import de.caritas.cob.messageservice.api.model.MessageStreamDTO;
import de.caritas.cob.messageservice.api.model.MessageType;
Expand Down Expand Up @@ -115,6 +115,7 @@ private MessageStreamDTO obtainMessageStream(String rcToken, String rcUserId, St
return restTemplate.exchange(uri, HttpMethod.GET, entity, MessageStreamDTO.class).getBody();

} catch (RestClientException exception) {
LogService.logRocketChatServiceError(exception);
throw new InternalServerErrorException(String.format(
"Could not read message stream from Rocket.Chat API (rcUserId: %s, rcGroupId: %s)",
rcUserId, rcGroupId), LogService::logRocketChatServiceError);
Expand Down Expand Up @@ -182,15 +183,15 @@ public PostMessageResponseDTO postGroupMessage(

message = XssProtection.escapeHtml(message);
message = encryptionService.encrypt(message, rcGroupId);
HttpHeaders headers = getRocketChatHeader(rcToken, rcUserId);
PostMessageDTO postMessageDTO = new PostMessageDTO(rcGroupId, message, alias);
HttpEntity<PostMessageDTO> request = new HttpEntity<>(postMessageDTO, headers);

try {
HttpHeaders headers = getRocketChatHeader(rcToken, rcUserId);
PostMessageDTO postMessageDTO = new PostMessageDTO(rcGroupId, message, alias);
HttpEntity<PostMessageDTO> request = new HttpEntity<>(postMessageDTO, headers);

return restTemplate.postForObject(rcPostMessageUrl, request, PostMessageResponseDTO.class);

} catch (Exception ex) {
LogService.logRocketChatServiceError(
"Request body which caused the error was " + request.getBody());
throw new InternalServerErrorException(ex, LogService::logRocketChatServiceError);
}
}
Expand Down

0 comments on commit faadc60

Please sign in to comment.