All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finagle.stats.CancelledCategorizer.scala Maven / Gradle / Ivy

There is a newer version: 21.2.0
Show newest version
package com.twitter.finagle.stats

import com.twitter.finagle.{CancelledConnectionException, CancelledRequestException}
import com.twitter.util.Throwables.RootCause

/**
 * Matcher for Throwables caused by some form of cancellation.
 */
object CancelledCategorizer {
  val Cancelled = "cancelled"

  def unapply(exc: Throwable): Option[Throwable] = {
    exc match {
      case t: CancelledRequestException => Some(t)
      case t: CancelledConnectionException => Some(t)
      case RootCause(CancelledCategorizer(t)) => Some(t)
      case _ => None
    }
  }

  val Instance: PartialFunction[Throwable, String] = {
    case CancelledCategorizer(_) => Cancelled
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy