intridea/grape — Issue #109: basic auth results in 500 on failure
Author: jjb
Created: 2012-01-03 20:23:26+00:00
State: open

I've implemented basic auth like this:

https://github.com/intridea/grape/wiki/Authentication

When given the correct credentials, it works.

However, when given the wrong credentials, I get

ArgumentError: uncaught throw :error
/Users/john/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/grape-0.1.5/lib/grape/middleware/auth/basic.rb:24:in `throw'
...

Which is a result of (this line of code)[https://github.com/intridea/grape/blob/master/lib/grape/middleware/auth/basic.rb#L24]. I've never used `throw` instead of `raise`, I don't know if this is a convention in Rack or how it's supposed to be handled... all the tests pass, including (this one)[https://github.com/intridea/grape/blob/master/spec/grape/middleware/auth/basic_spec.rb#L29] which checks if the response is 401...

Any idea why I'm getting a 500 instead of 401 in my environment?