Rack app error handling request { get
Additionally, however, you discover the intended functionality - the API requires a token, and that token must be passed as part of the request in order to gain authorization.
#RACK APP ERROR HANDLING REQUEST { GET CODE#
Error codes have an implied value in the way that they both clarify the situation, and communicate the intended functionality.Ĭonsider for instance an error code such as “401 Unauthorized – Please Pass Token.” In such a response, you understand the point of failure, specifically that the user is unauthorized. Error responses thus are the only truly constant, consistent communication the user can depend on when an error has occurred. It’s often the first and most important step towards not only notifying the user of a failure, but jump-starting the error resolution process.Ī user doesn’t choose when an error is generated, or what error it gets - error situations often arise in instances that, to the user, are entirely random and suspect. This stage, sitting after the initial request stage, is a direct communication between client and API. Error codes in the response stage of an API is the fundamental way in which a developer can communicate failure to a user. The Value of Error CodesĪs we’ve already said, error codes are extremely useful.
#RACK APP ERROR HANDLING REQUEST { GET HOW TO#
We’ll also talk a bit about what makes a “good” error code and what makes a “bad” error code, and how to ensure your error codes are up to snuff. We’ll take a look at some common error code classifications the average user will encounter, as well as some examples of these codes in action.
Today, we’re going to talk about exactly why error responses and handling approaches are so useful and important. Error codes are probably the most useful diagnostic element in the API space, and this is surprising, given how little attention we often pay them. That being said, errors, whether in code form or simple error response, are a bit like getting a shot - unpleasant, but incredibly useful.
In either situation, traffic comes crashing to a halt, and the process of discovering the cause and solution begins. Generally speaking, it means one of two things - something was so wrong in your request or your handling that the API simply couldn’t parse the passed data, or the API itself has so many problems that even the most well-formed request is going to fail. Error codes are almost the last thing that you want to see in an API response.