Open khionu opened 4 years ago
Pulling this through would also simplify error handling situations like these
Right now, the code handles errors in two different ways simultaneously: some kinds of errors (e.g. network errors) are propagated up the chain and not posted, and other errors (crate not found) are posted. By having all errors be printed by default, the error propagation operator could be used for both:
let krate = get_crate(&args)?;
args.msg.channel_id.send_message(&args.cx, |m| {
m.embed(|e| {
e.title(&krate.name)
.url(format!("https://crates.io/crates/{}", krate.id))
.description(&krate.description)
.field("version", &krate.version, true)
.field("downloads", &krate.downloads, true)
.timestamp(krate.updated.as_str())
});
m
})?;
"Crate not found" is not an error, from our perspective. It's expected behaviour for command invocations to provide invalid input. The idea behind this issue is that unexpected errors would provide some feedback to the user instead of the bot being silent, so we should have a case in the central command handler for sending a generic "an error occurred, please contact..." message
If a command encounters a non-fatal error, it should send the error as a response. Note, an invalid command should not be treated as an error.