=str more specific error type if idle-timeout triggers in tcp
This commit is contained in:
parent
4207682624
commit
e7e1f74427
12 changed files with 336 additions and 5 deletions
|
|
@ -269,6 +269,28 @@ final case class Recover[T](pf: PartialFunction[Throwable, T]) extends SimpleLin
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps error with the provided function if it is defined for an error or, otherwise, passes it on unchanged.
|
||||
*
|
||||
* While similar to [[Recover]] this stage can be used to transform an error signal to a different one *without* logging
|
||||
* it as an error in the process. So in that sense it is NOT exactly equivalent to `recover(t => throw t2)` since recover
|
||||
* would log the `t2` error.
|
||||
*/
|
||||
final case class MapError[T](f: PartialFunction[Throwable, Throwable]) extends SimpleLinearGraphStage[T] {
|
||||
override def createLogic(attr: Attributes) =
|
||||
new GraphStageLogic(shape) with InHandler with OutHandler {
|
||||
override def onPush(): Unit = push(out, grab(in))
|
||||
|
||||
override def onUpstreamFailure(ex: Throwable): Unit =
|
||||
if (f.isDefinedAt(ex)) super.onUpstreamFailure(f(ex))
|
||||
else super.onUpstreamFailure(ex)
|
||||
|
||||
override def onPull(): Unit = pull(in)
|
||||
|
||||
setHandlers(in, out, this)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue