interledger / interledger-rs

An easy-to-use, high-performance Interledger implementation written in Rust
http://interledger.rs
Other
198 stars 70 forks source link

Improve HTTP responses #250

Closed dora-gt closed 4 years ago

dora-gt commented 5 years ago

Currently HTTP endpoints return JSON like:

{"type":"about:blank","title":"Internal Server Error"}
or
{"type":"about:blank","title":"Bad Request"}

This tells nothing for developers and it's hard to assume what's the problem. We need to improve this.

https://interledger.slack.com/archives/CHC51E54J/p1566983918002000

emschwartz commented 5 years ago

It looks like we can use https://github.com/dtolnay/path-to-error along with the error message returned by serde_json to provide a more helpful error message

dora-gt commented 5 years ago

Because the testnet document depends on test.xpring.tech, I'll try to improve this in parallel.

dora-gt commented 5 years ago

memo:

dora-gt commented 5 years ago

I think there are 2 options to implement this.

  1. Improve tower-web
  2. Implement extract trait on our own
    • If we implement on our own, it might be more flexible. We could specify our own types like https://errors.interledger.org/<api>/<error_type>.
    • I haven't dug into this approach yet enough.

If you @interledger-rs/contributors have any opinion, please tell me.

emschwartz commented 5 years ago

I'm in the process of switching everything over to warp (away from tower-web) so I wouldn't focus on implementing this for tower-web.

warp gives you a bit more manual control over error handling so it shouldn't be too difficult to implement once we decide what we want. See how "rejections" are handled here. We can change our own ApiError type to include more details of the error and then change that error handling logic to include more details in the HTTP response body.

dora-gt commented 5 years ago

Ahhh! sorry, I forgot. Yes, we should use warp. Thank you. I'll check the code.

gakonst commented 4 years ago

Closing, our error handling is very nice now