From the course: Consuming RESTful APIs in Golang

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Error handling

Error handling

- [Instructor] Welcome to this video. In the last video, we looked at passing JSON from your API responses. In this video, we are looking at handling errors. Now error handling is a very important aspect in building your robust RESTful client in Go. Particular, error handling when you're working with an HTTP client is really, really important. There are different classes of errors that you will encounter and I want to go through three of them. The first class of errors that you'll encounter are what I call network errors. These particular errors have to do with reachability of your API of the servers you're trying to get data from. In this particular case, say for example, your client times out while connecting to your server. Your server is just temporarily unavailable. It's sticking down due to whatever reason. You call these network errors. The second kind of errors I like to refer to are HTTP status errors or unexpected HTTP statuses. And the first chapter we looked at REST APIs…

Contents