private[this] def handle()

in http-core/src/main/scala/com/twitter/finatra/http/marshalling/MessageInjectableValues.scala [158:191]


  private[this] def handle(
    valueId: Any,
    context: DeserializationContext,
    forProperty: BeanProperty,
    beanInstance: Any,
    fieldName: String,
    response: Response
  ): AnyRef = {
    try {
      if (isResponse(forProperty)) {
        response
      } else if (forProperty.getContextAnnotation(classOf[Header]) != null) {
        getHeader(context, forProperty, fieldName, response)
      } else if (Annotations.hasAnnotation(forProperty, requestParamsAnnotations)) {
        // request annotations are not supported for parsing a response
        val message =
          s"Unable to inject field '$fieldName'. ${classOf[Request].getSimpleName}-specific " +
            s"annotations: [${requestParamsAnnotations.map(a => s"@${a.getSimpleName}").mkString(", ")}] " +
            s"are not supported with a ${classOf[Response].getName}."
        throw InjectableValuesException(message)
      } else {
        // handle if the field is annotated with an injection annotation
        super.findInjectableValue(valueId, context, forProperty, beanInstance)
      }
    } catch {
      // Only translate `InvalidDefinitionException` to InjectableValuesException,
      // all others escape to be handled elsewhere.
      case ex: InvalidDefinitionException =>
        logger.debug(ex.getMessage, ex)
        throw InjectableValuesException(
          forProperty.getMember.getDeclaringClass,
          forProperty.getName)
    }
  }