Class HomeException
- Direct Known Subclasses:
HomeConfigurationException
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();
}
}
});
-
Constructor Summary
ConstructorsConstructorDescriptionHomeException(HomeError error, String message) Creates an exception carrying a typed reason.HomeException(HomeError error, String message, String accessoryId) Creates an exception carrying a typed reason and the accessory it applies to.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. -
Method Summary
Modifier and TypeMethodDescriptionThe accessory this failure is about, when it is about one.getError()The typed reason this operation failed.Methods inherited from class Throwable
addSuppressed, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
HomeException
Creates an exception carrying a typed reason.
Parameters
-
error: the typed reason;nullbecomesHomeError.UNKNOWN -
message: the platform's own text, or an explanation of a request this API rejected before it reached the platform
-
-
HomeException
Creates an exception carrying a typed reason and the accessory it applies to.
Parameters
-
error: the typed reason;nullbecomesHomeError.UNKNOWN -
message: the platform's own text -
accessoryId: the accessory the failure is about, ornullwhen it is not about one in particular
-
-
HomeException
Creates an exception carrying a typed reason, the accessory it applies to and an underlying cause.
Parameters
-
error: the typed reason;nullbecomesHomeError.UNKNOWN -
message: the platform's own text -
accessoryId: the accessory the failure is about, ornull -
cause: the underlying failure, ornull
-
-
-
Method Details
-
getError
The typed reason this operation failed.
Returns
the reason, never
null -
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
nullhere; per-item outcomes inside a batch that partially succeeded are reported throughTraitWriteResultandTraitReadinginstead, not as exceptions.Returns
the accessory id, or
null
-