shimoju / metabase-ruby

Ruby client library for Metabase API
MIT License
28 stars 27 forks source link

Detail error response #9

Closed shimoju closed 6 years ago

shimoju commented 6 years ago

エラーメッセージを親切にします。こんな感じになります。

レスポンスボディをそのまま入れてるので、HTMLが返ってきちゃったとき(上位のリバースプロキシでエラー返ってきたときとか)はめっちゃ長くなってしまいますが、それはまたあとでいい感じにします。

[2] pry(main)> client.login
Metabase::BadRequest: POST http://localhost:3030/api/session: 400 - {"errors"=>{"password"=>"did not match stored password"}}
from /Users/shimoju/local/src/github.com/shimoju/metabase-ruby/lib/metabase/connection.rb:37:in `request'
[3] pry(main)> client.current_user
Metabase::Unauthorized: GET http://localhost:3030/api/user/current: 401 - Unauthenticated
from /Users/shimoju/local/src/github.com/shimoju/metabase-ruby/lib/metabase/connection.rb:37:in `request'