This class helps distinguish "user" errors (such as calling a method of this library
without a required parameter) from remote API errors. When a remote API error occurs
(i.e., the server responds with a 4xx or 5xx) an ApiError is thrown.
An ApiError will have a status property with the response's HTTP status code, and
a message property with the response body (error message).
Example
try { awaitapi.getUnreadCounts() } catch (error) { if (errorinstanceofApiError) { console.log("Caught an ApiError:") console.log(`HTTP ${error.status}: ${error.message}`) } else { console.log("Some other error:", error) }
This class helps distinguish "user" errors (such as calling a method of this library without a required parameter) from remote API errors. When a remote API error occurs (i.e., the server responds with a
4xx
or5xx
) anApiError
is thrown.An
ApiError
will have astatus
property with the response's HTTP status code, and amessage
property with the response body (error message).Example