public class HomeException

  1. Object
  2. Throwable
  3. Exception
  4. HomeException

Known subtypesHomeConfigurationException

The failure delivered through an AsyncResource when a smart-home operation does not succeed. Branch on getError() rather than on the message.

SmartHome.getInstance().write(write).onResult((res, err) -> {
    if (err instanceof HomeException) {
        HomeError e = ((HomeException) err).getError();
        if (e == HomeError.PIN_REQUIRED) {
            promptForLockPin();
        }
    }
});

Constructors

public HomeException(HomeError error, String message)Creates an exception carrying a typed reason.
public HomeException(HomeError error, String message, String accessoryId)Creates an exception carrying a typed reason and the accessory it applies to.
public HomeException(HomeError error, String message, String accessoryId, Throwable cause)Creates an exception carrying a typed reason, the accessory it applies to and an underlying cause.

Methods

public HomeError getError()The typed reason this operation failed.
public String getAccessoryId()The accessory this failure is about, when it is about one.

Inherited methods

Constructor details

HomeException

public HomeException(HomeError error, String message)
Creates an exception carrying a typed reason.

Parameters

error HomeError
the typed reason; null becomes HomeError.UNKNOWN
message String
the platform’s own text, or an explanation of a request this API rejected before it reached the platform

HomeException

public HomeException(HomeError error, String message, String accessoryId)
Creates an exception carrying a typed reason and the accessory it applies to.

Parameters

error HomeError
the typed reason; null becomes HomeError.UNKNOWN
message String
the platform’s own text
accessoryId String
the accessory the failure is about, or null when it is not about one in particular

HomeException

public HomeException(HomeError error, String message, String accessoryId, Throwable cause)
Creates an exception carrying a typed reason, the accessory it applies to and an underlying cause.

Parameters

error HomeError
the typed reason; null becomes HomeError.UNKNOWN
message String
the platform’s own text
accessoryId String
the accessory the failure is about, or null
cause Throwable
the underlying failure, or null

Method details

getError

public HomeError getError()
The typed reason this operation failed.

Returns

the reason, never null

getAccessoryId

public String getAccessoryId()

The accessory this failure is about, when it is about one.

A batch read or write that fails as a whole has no single accessory and answers null here; per-item outcomes inside a batch that partially succeeded are reported through TraitWriteResult and TraitReading instead, not as exceptions.

Returns

the accessory id, or null