Exceptions
Every SDK call that talks to the network can throw NotificationHubException (unchecked — extends RuntimeException) or one of its typed subclasses. A single factory method, NotificationHubException.create(message, statusCode, body), picks the right subclass based on the HTTP status code returned by the API.
Hierarchy
Status code mapping
| HTTP status | Exception |
|---|---|
401, 403 | NotificationHubAuthException |
429 | NotificationHubRateLimitException |
400–499 (other) | NotificationHubValidationException |
500–599 | NotificationHubServerException |
| Anything else / network failure | NotificationHubException (status code 0 for local execution failures) |
Fields
| Field | Accessor | Description |
|---|---|---|
| status code | getStatusCode() | The HTTP status returned, or 0 for a local/network failure. |
| response body | getResponseBody() | The raw response body, if any. |
Handling exceptions
try {
client.notifications().send(request);
} catch (NotificationHubException.NotificationHubAuthException e) {
// Invalid or expired API key/secret — check your credentials
} catch (NotificationHubException.NotificationHubValidationException e) {
// Bad request — inspect e.getResponseBody() for details
} catch (NotificationHubException.NotificationHubRateLimitException e) {
// Back off and retry later
} catch (NotificationHubException.NotificationHubServerException e) {
// Transient server-side error — safe to retry with backoff
} catch (NotificationHubException e) {
// Network failure or unclassified error — e.getStatusCode() == 0 for local failures
}