DSpeckhals / bible.rs

A Bible server written in Rust using Actix Web and Diesel
https://bible.rs
MIT License
221 stars 24 forks source link

Add error alerting via Sentry #41

Closed DSpeckhals closed 5 years ago

DSpeckhals commented 5 years ago

This commit fixes a bug where a search value that starts with a number and ends with a space would throw a database error which was unhandled by the middleware. To fix this error, the query string is trimmed and an empty result set is returned. The error handling was also improved to log the underlying database error instead of a generic message.

In the process, I realized that it would be nice to be alerted to these types of issues instead of accidentally noticing them in a log. Sentry is a relatively simple option, so I added it. Unfortunately, though Sentry provides middleware for actix-web, it doesn't work yet for versions > 1.0. I copied and pasted code from this issue that lets the middleware work in a less-featured-than-ideal manner. I also added the Sentry panic handler.

little-eagle commented 5 years ago

@DSpeckhals Are you happy with how your Sentry patch is working? Thinking of rolling this out into my production actix-web app.

DSpeckhals commented 5 years ago

Are you happy with how your Sentry patch is working? Thinking of rolling this out into my production actix-web app.

It's worked out fine for my use case. I can't vouch for full functionality, though. If you copy the subdirectory out of this repo and make it part of a Cargo workspace, it should work.

It will be nice when Sentry gets the library 1.0 compatible, but until then...