Skip to content

Robust error handling when interacting with API #22

@dec4234

Description

@dec4234

The current REST interactions with the API frequently swallow errors and throw up NullPointerExceptions without much warning.
A more robust error handling system is in order. It should give the user the option to check for errors wherever the library sends a request. This may require rather large breaking changes.

Take DestinyAPI.getMemberFromSteamID

We want to wrap the return with some sort of container which can be checked.

public static Response<BungieUser> getMemberFromSteamID(String steamID) {
        return getMemberFromPlatformID("SteamId", steamID);
}

Then when handling the result we should be able to use functions like

response.isOkay() // if the request completed ok
response.isError() // api returned an error
response.getErrorMessage() // return error message from api
response.inner() // returns the BungieUser object
response.isApiOnline() // is the api online? or was it another error
response.inherit(new object) // pass error messages and such with a new object, like converting jsonobject to BungieUser

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions