Class StatusReply<T>
- java.lang.Object
-
- akka.pattern.StatusReply<T>
-
- Type Parameters:
T- the type of value a successful reply would have
public final class StatusReply<T> extends java.lang.ObjectGeneric top-level message type for replies that signal failure or success. Convenient to use together with theaskWithStatusask variants.Create using the factory methods
success(T)anderror(java.lang.String).Akka contains predefined serializers for the wrapper type and the textual error messages.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStatusReply.Error$Scala API for creating and pattern matching an error responsestatic classStatusReply.ErrorMessageCarrier exception used for textual error descriptions.static classStatusReply.ErrorMessage$static classStatusReply.Success$Scala API for creation and pattern matching a successful response.
-
Constructor Summary
Constructors Constructor Description StatusReply()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StatusReply<Done>ack()Java API: A general purpose message for using as an Ackstatic StatusReply<Done>Ack()Scala API: A general purpose message for using as an Ackbooleanequals(java.lang.Object other)static <T> StatusReply<T>error(java.lang.String errorMessage)Java API: Create an status response with a error message describing why the request was failed or denied.static <T> StatusReply<T>error(java.lang.Throwable exception)Java API: Create an error response with a user definedThrowable.static <T> StatusReply<T>fromTry(scala.util.Try<T> status)Scala API: Turn a try into a status reply.static <T> StatusReply<T>fromTryKeepException(scala.util.Try<T> status)Scala API: Turn a Try into a status reply.java.lang.ThrowablegetError()Java API: returns the exception if the reply is a failure, or throws an exception if not.TgetValue()Java API: in the case of a successful reply returns the value, if the reply was not successful the exception the failure was created with is throwninthashCode()booleanisError()booleanisSuccess()static <T> StatusReply<T>success(T value)Java API: Create a successful reply containingvaluejava.lang.StringtoString()
-
-
-
Method Detail
-
Ack
public static StatusReply<Done> Ack()
Scala API: A general purpose message for using as an Ack
-
ack
public static StatusReply<Done> ack()
Java API: A general purpose message for using as an Ack
-
success
public static <T> StatusReply<T> success(T value)
Java API: Create a successful reply containingvalue
-
error
public static <T> StatusReply<T> error(java.lang.String errorMessage)
Java API: Create an status response with a error message describing why the request was failed or denied.
-
error
public static <T> StatusReply<T> error(java.lang.Throwable exception)
Java API: Create an error response with a user definedThrowable.Prefer the string based error response over this one when possible to avoid tightly coupled logic across actors and passing internal failure details on to callers that can not do much to handle them.
For cases where types are needed to identify errors and behave differently enumerating them with a specific set of response messages may be a better alternative to encoding them as generic exceptions.
Also note that Akka does not contain pre-build serializers for arbitrary exceptions.
-
fromTryKeepException
public static <T> StatusReply<T> fromTryKeepException(scala.util.Try<T> status)
Scala API: Turn a Try into a status reply.Prefer the string based error response over this one when possible to avoid tightly coupled logic across actors and passing internal failure details on to callers that can not do much to handle them.
fromTry(scala.util.Try<T>)provides a convenience factory doing that forTry.For cases where types are needed to identify errors and behave differently enumerating them with a specific set of response messages may be a better alternative to encoding them as generic exceptions.
Also note that Akka does not contain pre-built serializers for arbitrary exceptions.
-
fromTry
public static <T> StatusReply<T> fromTry(scala.util.Try<T> status)
Scala API: Turn a try into a status reply.Transforms exceptions into status reply errors containing just the exception message string.
See
fromTryKeepException(scala.util.Try<T>)for passing the exception along as is.
-
getValue
public T getValue()
Java API: in the case of a successful reply returns the value, if the reply was not successful the exception the failure was created with is thrown
-
getError
public java.lang.Throwable getError()
Java API: returns the exception if the reply is a failure, or throws an exception if not.
-
isError
public boolean isError()
-
isSuccess
public boolean isSuccess()
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-