carbocation / go-instagram

Go library for accessing Instagram REST and Search APIs
BSD 2-Clause "Simplified" License
51 stars 20 forks source link

Better error handling #4

Closed Volox closed 9 years ago

Volox commented 9 years ago

Hi, i refactored some code to support native errors from Instagram. Now by using type assertion i can check if the error is an instagram.InstagramError. This enables to find rete limit errors such as OAuthRateLimitException.

Example:

ig, _ = instagram.NewClient(nil)
_, _, err := ig.Tags.RecentMedia("test", nil)
if igErr, ok := err.(*instagram.InstagramError); ok {
  fmt.Printf("InstagramError %s (%d): %s", igErr.ErrorType, igErr.Code, igErr.ErrorMessage)
}
carbocation commented 9 years ago

At a glance this looks great. Tied up working in the ICU until Sunday and will take a look then.

Thanks!

On Thursday, February 12, 2015, Riccardo Volonterio < notifications@github.com> wrote:

Hi, i refactored some code to support native errors from Instagram. Now by using type assertion i can check if the error is an instagram.InstagramError. This enables to find rete limit errors such as OAuthRateLimitException.

Example:

ig, = instagram.NewClient(nil), _, err := ig.Tags.RecentMedia("test", nil)if igErr, ok := err.(*instagram.InstagramError); ok { fmt.Printf("InstagramError %s (%d): %s", igErr.ErrorType, igErr.Code, igErr.ErrorMessage) }


You can view, comment on, or merge this pull request online at:

https://github.com/carbocation/go-instagram/pull/4 Commit Summary

  • Added InstagramError for better error handling

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/carbocation/go-instagram/pull/4.