Skip to content

Instantly share code, notes, and snippets.

@baxtheman
Created February 8, 2016 14:01
Show Gist options
  • Save baxtheman/25d7d79a9f8c46e218b8 to your computer and use it in GitHub Desktop.
Save baxtheman/25d7d79a9f8c46e218b8 to your computer and use it in GitHub Desktop.
public static void notifyError(final Throwable e) {
try {
if (Validator.isNull(PortletPropsValues.WEBHOOK_LOG_URL)) {
return;
}
final StringBuilder sb = new StringBuilder();
sb.append("machine: " + PortalUtil.getComputerName());
sb.append("\n");
for (StackTraceElement element : e.getStackTrace()) {
sb.append(element.toString());
sb.append("\n");
}
HttpResponse<String> jsonResponse =
Unirest.post(PortletPropsValues.WEBHOOK_LOG_URL)
.field("payload",new JSONObject(){{
put("pretext", e.getMessage());
put("text", sb.toString());
put("color", "#D00000");
}})
.asString();
}
catch (Exception e1) {
_log.error(e1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment