From 1d25d3f1f2b2aa117b78d395226efd2cb9ea39ac Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 18 Jan 2018 19:26:52 +0300 Subject: api: log fb post errors --- juick-api/src/main/java/com/juick/api/TopManager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'juick-api/src/main/java') diff --git a/juick-api/src/main/java/com/juick/api/TopManager.java b/juick-api/src/main/java/com/juick/api/TopManager.java index b7734a1b..b8123639 100644 --- a/juick-api/src/main/java/com/juick/api/TopManager.java +++ b/juick-api/src/main/java/com/juick/api/TopManager.java @@ -23,8 +23,10 @@ import com.juick.util.MessageUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; import javax.inject.Inject; @@ -43,7 +45,13 @@ public class TopManager { messagesService.setMessagePopular(m, 1); Message jmsg = messagesService.getMessage(m); String status = MessageUtils.getMessageHashTags(jmsg) + StringUtils.defaultString(jmsg.getText()); - facebookPageManager.post(status, "https://juick.com/" + jmsg.getMid()); + try { + facebookPageManager.post(status, "https://juick.com/" + jmsg.getMid()); + } catch (HttpClientErrorException ex) { + HttpStatus statusCode = ex.getStatusCode(); + String responseString = ex.getResponseBodyAsString(); + logger.warn("facebook error {}: {}", statusCode.value(), responseString); + } }); } } -- cgit v1.2.3