eHUB Provider API errors are communicated through HTTP status codes and a JSON messages that contain a more detailed explanation of the error. HTTP responses with a status code >399 should contain a message that explains the error. Aside from these the API might reply with a HTTP status code >= 500 for internal errors. Please note that errors should never send responses with HTTP status 200 (OK). Usually HTTP status 500 (Internal Server Error) is a good choice.
JSON messages have the following format:
{ "message": <error message>, "code": <error code> }
In the above:
<message> | A detailed error message explaining the problem. This message is not shown to the eHUB users, but logged in the application log. |
<code> | Error code. There are 2 types of error codes:
|
{ "message": "Not enough credit for this transaction", "code": "BORROWER_LIMIT_REACHED" }
The following standard error codes are defined in eHUB Provider API
BORROWER_LIMIT_REACHED | You have reached your limit when it comes to the number of e-media loans |
INACTIVE_LOAN | The loan is no longer active |
LIBRARY_LIMIT_REACHED | The library has reached its limit when it comes to the number of e-media loans |
MAX_NO_OF_DOWNLOADS_FOR_PRODUCT_REACHED | The maximum number of downloads has been reached for this book |
MISSING_CONTENT_IN_LOAN | The loan does not contain any content |
PRODUCT_INACTIVE | The book is inactive and is therefore unavailable to loan |
PRODUCT_UNAVAILABLE | The book is unavailable to loan when it lacks a valid business model |
INVALID_CONTENT_PROVIDER_RECORD_ID | The provided Content Provider Record ID is invalid |
INVALID_REGION_ID | The configured Region ID is invalid |
INVALID_FORMAT_ID | The ID of the requested format is invalid |
CREATE_LOAN_FAILED | Could not create loan |
INVALID_LOAN_ID | The format of the provided loan ID is invalid |
CHECKOUT_NOT_FOUND | Your checkout for this title could not be found |
ALREADY_ON_LOAN | The record is already loaned to this patron |
INVALID_PATRON | Invalid patron |
ANOTHER_FORMAT_LOCKED_IN | Another format has already been locked in |
UNFULFILLED_AGE_LIMIT | Unfulfilled age limit |