mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-27 21:46:04 +02:00
![twitter-team](/assets/img/avatar_default.png)
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
30 lines
1.1 KiB
Scala
30 lines
1.1 KiB
Scala
package com.twitter.home_mixer.module
|
|
|
|
import com.twitter.finatra.thrift.exceptions.ExceptionMapper
|
|
import com.twitter.home_mixer.{thriftscala => t}
|
|
import com.twitter.inject.Logging
|
|
import com.twitter.product_mixer.core.pipeline.pipeline_failure.PipelineFailure
|
|
import com.twitter.product_mixer.core.pipeline.pipeline_failure.ProductDisabled
|
|
import com.twitter.scrooge.ThriftException
|
|
import com.twitter.util.Future
|
|
import javax.inject.Singleton
|
|
|
|
@Singleton
|
|
class PipelineFailureExceptionMapper
|
|
extends ExceptionMapper[PipelineFailure, ThriftException]
|
|
with Logging {
|
|
|
|
def handleException(throwable: PipelineFailure): Future[ThriftException] = {
|
|
throwable match {
|
|
// SliceService (unlike UrtService) throws an exception when the requested product is disabled
|
|
case PipelineFailure(ProductDisabled, reason, _, _) =>
|
|
Future.exception(
|
|
t.ValidationExceptionList(errors =
|
|
Seq(t.ValidationException(t.ValidationErrorCode.ProductDisabled, reason))))
|
|
case _ =>
|
|
error("Unhandled PipelineFailure", throwable)
|
|
Future.exception(throwable)
|
|
}
|
|
}
|
|
}
|