ApiError
Extends:
A custom error class to encapsulate errors thrown by FetchUtil.nprApiFetch. Behaves like a generic JavaScript error, but has additional metadata attached to it in case consuming code needs to be able to respond to specific kinds of errors.
Example:
nprOneSDK.setUserStation(123)
.catch((error) => {
if (error instanceof ApiError) {
if (error.statusCode === 401) {
Logger.debug('The response was a 401!');
} else {
Logger.debug('The response was not a 401!');
}
}
});
Constructor Summary
Public Constructor | ||
public |
constructor(response: Response, json: Object) Creates a new, custom error using the Fetch Response object as its basis. |
Member Summary
Public Members | ||
public |
The headers associated with the response. |
|
public |
Contains the decoded JSON of the response, if any. |
|
public |
Contains the type of the response (e.g., basic, cors). |
|
public |
Contains the URL of the response. |
|
public |
The status code of the response (e.g., |
|
public |
The status message corresponding to the status code (e.g., |
Public Constructors
public constructor(response: Response, json: Object) source
Creates a new, custom error using the Fetch Response object as its basis.
Params:
Name | Type | Attribute | Description |
response | Response | The actual raw Fetch Response from the failed API call |
|
json | Object |
|
If available, the decoded JSON from the error response |