dustinlakin / twitch-rb

Twitch API gem
MIT License
51 stars 28 forks source link

Execution continues even in an error state #16

Open VxJasonxV opened 8 years ago

VxJasonxV commented 8 years ago

I've written a few simple scripts against this gem, and noticed some false positives where the script continues to execute even with an failure API return. It seems that if the API doesn't return at all (HTTP Timeout) then the script halts execution, but if it returns with a 503, it continues:

{
    :body => {
         "cache-control" => [
            [0] "no-cache"
        ],
          "content-type" => [
            [0] "text/html"
        ],
                  "date" => [
        ],
            [0] "Thu, 24 Mar 2016 20:44:26 GMT"
        ],
                "server" => [
            [0] "nginx"
        "content-length" => [
            [0] "107"
        ],
            "connection" => [
            [0] "Close"
        ]
    }
    :response => 503
},

Non-OK HTTP returns should raise a rescue'able error, and halt execution.

djhopper01 commented 8 years ago

@VxJasonxV I started working on this here: https://github.com/djhopper01/twitch-rb/commit/1a07fb5770ba5dfe1a976f4b77664a07f0a6bf55. Once I add a spec for it, I'll open up a PR.