Skip to content

Commit a0793f9

Browse files
committed
rewrite error handling section in the README
1 parent 2aae8c3 commit a0793f9

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,29 +1562,23 @@ try {
15621562

15631563

15641564

1565-
## Exceptions
1565+
## Error Handling
15661566

1567-
### Auth0Exception
1568-
Base checked exception thrown when a Request creation or execution fails.
1567+
The API Clients throw `Auth0Exception` when an unexpected error happens on a request execution, i.e. Connectivity or Timeout error.
15691568

1570-
```java
1571-
try {
1572-
request.execute();
1573-
} catch(Auth0Exception e) {
1574-
e.getMessage(); // description
1575-
}
1576-
```
1569+
If you need to handle different error scenarios you need to catch first `APIException`, which provides methods to get a clue of what went wrong.
15771570

1578-
### APIException
1579-
Auth0Exception child thrown when the Request was executed fine but the Response was not successful.
1571+
The APIExplorer includes a list of response messages for each endpoint. You can get a clue of what went wrong by asking the Http status code: `exception.getStatusCode()`. i.e. a `status_code=403` would mean that the token has an insufficient scope.
15801572

1581-
```java
1582-
try {
1583-
request.execute();
1584-
} catch(APIException e) {
1585-
e.getStatusCode(); // http status code
1586-
e.getError(); // api error code
1587-
e.getDescription(); // api error description
1573+
An error code will be included to categorize the type of error, you can get it by calling `exception.getError()`. If you want to see a user friendly description of what happened and why the request is failing check the `exception.getDescription()`.
1574+
1575+
1576+
```
1577+
Example exception data
1578+
{
1579+
statusCode: 400,
1580+
description: "Query validation error: 'String 'users' does not match pattern. Must be a comma separated list of the following values: name,strategy,options,enabled_clients,id,provisioning_ticket_url' on property fields (A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields).",
1581+
error: "invalid_query_string"
15881582
}
15891583
```
15901584

0 commit comments

Comments
 (0)