public class 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
errorHomeError- the typed reason;
nullbecomesHomeError.UNKNOWN messageString- 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
errorHomeError- the typed reason;
nullbecomesHomeError.UNKNOWN messageString- the platform’s own text
accessoryIdString- the accessory the failure is about, or
nullwhen 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
errorHomeError- the typed reason;
nullbecomesHomeError.UNKNOWN messageString- the platform’s own text
accessoryIdString- the accessory the failure is about, or
null causeThrowable- the underlying failure, or
null
Method details
getError
public HomeError getError()The typed reason this operation failed.
Returns
the reason, never
nullgetAccessoryId
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