djc / askama

Type-safe, compiled Jinja-like templates for Rust
Apache License 2.0
3.43k stars 218 forks source link

Provide a `Sync` error (aka don't use error-chain) #92

Closed rustonaut closed 6 years ago

rustonaut commented 6 years ago

Errors from error-chain are not Sync, which can cause problems in some cases. E.g. if you want to/have to use Failure which requires Send+Sync bounds.

As askama doesn't really have many errors it should be simple.


Currently askama has two foreign links and that's it:

  1. ::std::fmt::Error (which is zero-sized)
  2. [feature] ::serde_json::Error (which is a custom error impl)

I think it might be the best to roll a simple error enum, as people might use either failure or error-chain or custom errors and a simple error enum is compatible with all this ways (note that you would have to make it non-exhaustive)

rustonaut commented 6 years ago

I also noticed that it does not expose the ErrorKind making it impossible to match the error kinds and convert it to a wrapper implementing Sync.

djc commented 6 years ago

Sounds sensible. Would you be able to submit a PR?

rustonaut commented 6 years ago

Yes, probably not today but in the next 1-2 days.

On Sun, Jun 3, 2018, 15:04 Dirkjan Ochtman notifications@github.com wrote:

Sounds sensible. Would you be able to submit a PR?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/djc/askama/issues/92#issuecomment-394161060, or mute the thread https://github.com/notifications/unsubscribe-auth/AHR0kThO4AbLEHiNcpeAVdJnf6g40p5Iks5t497VgaJpZM4UU9hL .

djc commented 6 years ago

Great, thanks!

djc commented 6 years ago

Fixed by 12c920d7e34dae4934d52072ab9d8cb271d71058.