<commit_before>package services

import javax.inject.Inject

import scala.concurrent.ExecutionContext
import scala.util.{ Failure, Success, Try }

import play.api.{ Configuration, Logger }
import play.api.libs.json.JsObject
import play.api.libs.ws.WSRequest

case class WebHook(name: String, ws: WSRequest)(implicit ec: ExecutionContext) {
  private[WebHook] lazy val logger = Logger(getClass.getName + "." + name)

  def send(obj: JsObject) = ws.post(obj).onComplete {
    case Success(resp) if resp.status / 100 != 2 ⇒ logger.error(s"WebHook returns status ${resp.status} ${resp.statusText}")
    case Failure(error)                          ⇒ logger.error("WebHook call error", error)
    case _                                       ⇒
  }
}<commit_msg>#293 hide stacktrace if connection to web hook fails<commit_after>package services

import java.net.ConnectException
import javax.inject.Inject

import scala.concurrent.ExecutionContext
import scala.util.{ Failure, Success, Try }

import play.api.{ Configuration, Logger }
import play.api.libs.json.JsObject
import play.api.libs.ws.WSRequest

case class WebHook(name: String, ws: WSRequest)(implicit ec: ExecutionContext) {
  private[WebHook] lazy val logger = Logger(getClass.getName + "." + name)

  def send(obj: JsObject) = ws.post(obj).onComplete {
    case Success(resp) if resp.status / 100 != 2 ⇒ logger.error(s"WebHook returns status ${resp.status} ${resp.statusText}")
    case Failure(ce: ConnectException)           ⇒ logger.error(s"Connection to WebHook $name error", ce)
    case Failure(error)                          ⇒ logger.error("WebHook call error", error)
    case _                                       ⇒
  }
}
{'fraction_non_alphanumeric': 0.11124260355029586, 'fraction_numerical': 0.00650887573964497, 'mean_word_length': 3.1856435643564356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3006217', 'n_tokens_mistral': 508, 'n_tokens_neox': 495, 'n_words': 136}