XAMPPRocky / fluent-templates

Easily add Fluent to your Rust project.
Apache License 2.0
137 stars 29 forks source link

Pass through bundle errors? Don't panic! #8

Closed tmpfs closed 4 years ago

tmpfs commented 4 years ago

Hi XAMPPRocky,

I am using fluent-templates with the ArcLoader and Handlebars and it is working really well so far - thank you!

I noticed that when I call build() on the ArcLoaderBuilder that if I make an error it will panic due to the calls to expect() in build(). For my project that means I have to use std::panic::set_hook() to trap those errors which is not ideal.

Because ArcLoaderBuilder.build already returns a Result with the Error trait I think it would make more sense to just pass those errors back to the caller untouched - I am a beginner with Rust so not totally sure but I think it is more idiomatic to return them (?).

Happy to take a look at it further and submit a PR if you think this approach is worthwhile.

XAMPPRocky commented 4 years ago

Thank you for your issue! A PR fixing this would be welcome. I've linked where the expects are below.

https://github.com/XAMPPRocky/fluent-templates/blob/ca0284f4e3fe6711b3290126d20fe3865c5b2f89/templates/src/loader/arc_loader.rs#L56-L62