Result
The result of an asynchronous operation.
If operation was successful the result will be represented as Success with value as a payload.
If operation failed, result will be a Failure with the payload describing the failure.
Note that for idiomatic Kotlin you can use when
expression to safely access value or errorCode and other methods like this:
when (result) {
is Success -> println(result.value)
is Failure ->
println("${result.errorCode}: ${result.errorMessage}. Debug code: ${result.debugCode}")
}
From Java you can use one of helper methods: isSuccess() or isFailure() to define what kind of result you are dealing with. After that you can safely call value() or errorCode() to access the payload.
if (result.isSuccess()) {
println(result.value())
} else if (result.isFailure()) {
println(result.errorCode() + ": " + result.errorMessage() + ". Debug code: " + result.debugCode())
}
Note: an attempt to access failure payload on a success result or vice-versa will throw an IllegalStateException.
Parameters
The success value if the operation was successful.
Error code type in the payload that provides insight about the failure.
Inheritors
Functions
Human-readable message containing additional debug information related to the possible cause of the failure.
More detailed descriptions of the error(s) causing the failure, if available. In many cases these are the actual errors returned from a server call. It is possible for a failure to happen without more detail that provided by the other fields, and this will be an empty list in such cases. (For example, error code NOT_AUTHORIZED has no additional details, the developer simply needs to call AuthorizationManager.authorize() before using the failing Mobile Payments SDK method).
Displayable message that summarizes the possible cause of the failure.
true
if the operation resulted in a failure. For details see errorCode, errorMessage, debugCode and debugMessage.