dblock / slack-gamebot

Ping pong, chess, pool and other games bot for Slack.
MIT License
129 stars 103 forks source link

Transform API errors into 400 status code #48

Closed dblock closed 8 years ago

dblock commented 8 years ago

Right now just throwing 500s.

2015-12-19T16:17:47.223437+00:00 heroku[router]: at=info method=POST path="/teams" host=pong.playplay.io request_id=cf76358c-a2db-4bac-a5c0-88cc92726d66 fwd="24.90.107.1" dyno=web.1 connect=0ms service=965ms status=500 bytes=154
2015-12-19T16:17:47.223893+00:00 app[web.1]:   Validation of Team failed.
2015-12-19T16:17:47.223885+00:00 app[web.1]: 2015-12-19 16:17:47 +0000: Rack app error: #<Mongoid::Errors::Validations: 
2015-12-19T16:17:47.223891+00:00 app[web.1]: message:
2015-12-19T16:17:47.223894+00:00 app[web.1]: summary:
2015-12-19T16:17:47.223894+00:00 app[web.1]:   The following errors were found: Token is already taken
2015-12-19T16:17:47.223895+00:00 app[web.1]: resolution:
2015-12-19T16:17:47.224315+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/persistable/creatable.rb:175:in `create!'
2015-12-19T16:17:47.224304+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/persistable.rb:78:in `fail_due_to_validation!'