Giter VIP home page Giter VIP logo

Comments (5)

piotrmurach avatar piotrmurach commented on May 19, 2024

Hi Darren, yeah this looks too brittle for what it needs to be. I will try to tackle this one and simplify it asap, however in the meantime if you have any suggestions how this should be handled please send in a patch. Thanks Piotr

from github.

jensendarren avatar jensendarren commented on May 19, 2024

Thank you for your feedback. I may send you a patch when I have time :)

from github.

piotrmurach avatar piotrmurach commented on May 19, 2024

Hi Darren, I've spent some time on this issue and rewrote the error handling to always return a string message. All the response decoding and message extraction now happens inside the gem, therefore your code can be simplified as follows:

begin
    #Do something with github_api gem
rescue Github::Error::GithubError => e
  puts e.message => #e.g. 'key is already in use'
end

Please note that you can further refine your error catching to only GitHub service errors by using Github::Error::ServiceError etc.. plus I've updated the README with error handling information for future reference.

I hope this helps. Please download the v0.6.4 gem release and let us know if that's working for you?

P

from github.

jensendarren avatar jensendarren commented on May 19, 2024

I tried it out and it works! The message content includes the HTTP verb and the url (as well as the error message) by the way, for example, I received: "POST https://api.github.com/repos/jensendarren/try_git/keys?access_token=003betc7uwehblahblah7wj: 422 key is already in use"

Anyway, e.message.class is now a String which is great! Thanks Peter!

from github.

piotrmurach avatar piotrmurach commented on May 19, 2024

Awesome, I figured that having the explicit request information together with error message will make it more convenient for future debugging. Glad it works for you.

from github.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.