bytesnake / telebot

Write Telegram bots in Rust with Tokio and Futures
Other
212 stars 33 forks source link

Remove unwraps, reorganizing where needed #15

Closed asonix closed 6 years ago

asonix commented 6 years ago

My project AdminBot has crashed a few times while I wasn't watching due to some .unwrap()s somewhere in the dependencies, but I haven't been able to isolate exactly where.

In order to avoid this issue, I've attempted to handle every case in Telebot where .unwrap() was used with some logic that doesn't involve panicking. In many places, this was doable by expanding on the .and_then() chains already present in the code.

I've done some light testing of these changes with my Telecord project, and verified that I can still send and receive text and files.

Some formatting unrelated to the .unwrap()s changed since my text editor automatically runs rustfmt

bytesnake commented 6 years ago

Well the error handling is at the moment improvable, perhaps we can switch to the promoted failure crate. I'll will look through the pull request, but I've noticed two things:

  1. Conversion between result and future is quite messy (the Try operator would be helpful)
  2. It would have been good if the formatting and code change were in seperate commits