Class Result

Represents the result of a service call.

Constant Summary 

ConstantDescription
ERROR: String = “ERROR”Status indicating a general service error.
OK: String = “OK”Status indicating a successful service call.
SERVICE_UNAVAILABLE: String = “SERVICE_UNAVAILABLE”Status indicating the service is unavailable.
UNAVAILABLE_CIRCUIT_BROKEN: String = “CIRCUIT_BROKEN”Unavailable reason: No call was made because the circuit breaker prevented it.
UNAVAILABLE_CONFIG_PROBLEM: String = “CONFIG_PROBLEM”Unavailable reason: No call was made because the service was not configured correctly.
UNAVAILABLE_DISABLED: String = “DISABLED”Unavailable reason: No call was made because the service is disabled.
UNAVAILABLE_RATE_LIMITED: String = “RATE_LIMITED”Unavailable reason: No call was made because the rate limit was hit.
UNAVAILABLE_TIMEOUT: String = “TIMEOUT”Unavailable reason: A real call was made but a timeout occurred.

Property Summary 

PropertyDescription
error: Number (read-only)Returns an error-specific code if applicable.
errorMessage: String (read-only)Returns an error message on a non-OK status.
mockResult: Boolean (read-only)Returns the status of whether the response is the result of a “mock” service call.
msg: String (read-only)Returns an extra error message on failure (if any).
object: Object (read-only)Returns the actual object returned by the service when the status is OK.
ok: Boolean (read-only)Returns the status of whether the service call was successful.
status: String (read-only)Returns the status.
unavailableReason: String (read-only)Returns the reason the status is SERVICE_UNAVAILABLE.

Constructor Summary 

ConstructorDescription
Result()Constructs a new result instance.

Method Summary 

MethodDescription
getError()Returns an error-specific code if applicable.
getErrorMessage()Returns an error message on a non-OK status.
getMsg()Returns an extra error message on failure (if any).
getObject()Returns the actual object returned by the service when the status is OK.
getStatus()Returns the status.
getUnavailableReason()Returns the reason the status is SERVICE_UNAVAILABLE.
isMockResult()Returns the status of whether the response is the result of a “mock” service call.
isOk()Returns the status of whether the service call was successful.
toString()Returns a string representation of the result.

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Constant Details 

ERROR 

ERROR: String = "ERROR"

Status indicating a general service error.


OK 

OK: String = "OK"

Status indicating a successful service call.


SERVICE_UNAVAILABLE 

SERVICE_UNAVAILABLE: String = "SERVICE_UNAVAILABLE"

Status indicating the service is unavailable. This includes timeouts, rate limits, and remote server issues.


UNAVAILABLE_CIRCUIT_BROKEN 

UNAVAILABLE_CIRCUIT_BROKEN: String = "CIRCUIT_BROKEN"

Unavailable reason: No call was made because the circuit breaker prevented it.


UNAVAILABLE_CONFIG_PROBLEM 

UNAVAILABLE_CONFIG_PROBLEM: String = "CONFIG_PROBLEM"

Unavailable reason: No call was made because the service was not configured correctly.


UNAVAILABLE_DISABLED 

UNAVAILABLE_DISABLED: String = "DISABLED"

Unavailable reason: No call was made because the service is disabled.


UNAVAILABLE_RATE_LIMITED 

UNAVAILABLE_RATE_LIMITED: String = "RATE_LIMITED"

Unavailable reason: No call was made because the rate limit was hit.


UNAVAILABLE_TIMEOUT 

UNAVAILABLE_TIMEOUT: String = "TIMEOUT"

Unavailable reason: A real call was made but a timeout occurred.


Property Details 

error 

error: Number (read-only)

Returns an error-specific code if applicable. For example, this is the HTTP response code for an HTTPService.


errorMessage 

errorMessage: String (read-only)

Returns an error message on a non-OK status.


mockResult 

mockResult: Boolean (read-only)

Returns the status of whether the response is the result of a "mock" service call.


msg 

msg: String (read-only)

Returns an extra error message on failure (if any).


object 

object: Object (read-only)

Returns the actual object returned by the service when the status is OK.


ok 

ok: Boolean (read-only)

Returns the status of whether the service call was successful.


status 

status: String (read-only)

Returns the status. This is "OK" on success. Failure codes include "ERROR" and "SERVICE_UNAVAILABLE".

If the status is "SERVICE_UNAVAILABLE", then the unavailableReason is guaranteed to be non-null.

See Also:


unavailableReason 

unavailableReason: String (read-only)

Returns the reason the status is SERVICE_UNAVAILABLE.

See Also:


Constructor Details 

Result() 

Result()

Constructs a new result instance.


Method Details 

getError() 

getError(): Number

Returns an error-specific code if applicable. For example, this is the HTTP response code for an HTTPService.

Returns:

  • Error-specific code (if applicable).

getErrorMessage() 

getErrorMessage(): String

Returns an error message on a non-OK status.

Returns:

  • Error message.

getMsg() 

getMsg(): String

Returns an extra error message on failure (if any).

Returns:

  • Error message, or null.

getObject() 

getObject(): Object

Returns the actual object returned by the service when the status is OK.

Returns:

  • Object returned by the service.

getStatus() 

getStatus(): String

Returns the status. This is "OK" on success. Failure codes include "ERROR" and "SERVICE_UNAVAILABLE".

If the status is "SERVICE_UNAVAILABLE", then the unavailableReason is guaranteed to be non-null.

Returns:

  • Status code.

See Also:


getUnavailableReason() 

getUnavailableReason(): String

Returns the reason the status is SERVICE_UNAVAILABLE.

Returns:

  • Unavailable reason code, or null if the status is not SERVICE_UNAVAILABLE.

See Also:


isMockResult() 

isMockResult(): Boolean

Returns the status of whether the response is the result of a "mock" service call.

Returns:

  • true if this was a mock service call, false otherwise.

isOk() 

isOk(): Boolean

Returns the status of whether the service call was successful.

Returns:

  • true on success, false otherwise.

toString() 

toString(): String

Returns a string representation of the result.

Returns:

  • a string representation of the result.