VictorAvelar / devto-api-go

A go client for the dev.to API
https://docs.dev.to/api/
MIT License
1 stars 2 forks source link

Handle error HTTP statuses #5

Closed andyhaskell closed 5 years ago

andyhaskell commented 5 years ago

Description

This PR defines a type for responses given in non-2xx error statuses for dev.to endpoints so that we can

Motivation and context

The net/http client's Do method does not return errors for 4xx and 5xx statuses, so we need code for checking for error HTTP responses.

How has this been tested?

This PR adds to the test coverage for each endpoint to handle 4xx error responses

Screenshots (if appropriate)

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.

Question on the documentation, I noticed that there is a README.md in the docs directory explaining each type. Would you rather have this documentation just be in the Godoc with a Godoc badge so it stays up to date with what's served in https://godoc.org/github.com/VictorAvelar/devto-api-go/devto, and then instead have docs such as usage examples in the main README?

If you're unsure about any of these, don't hesitate to ask. We're here to help!

andyhaskell commented 5 years ago

@VictorAvelar just got rid of Gorilla Mux and renamed non2xx so this should be ready for another look

VictorAvelar commented 5 years ago

I will merge this one and tag v1, so that we can start tracking changes using SemVer, thanks for your effort.