diff options
| author | Teddy Wing | 2016-04-27 16:46:07 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-04-27 16:46:07 -0400 |
| commit | f45f00cbbe32d473deb4e23e8944a5a61e5f8e45 (patch) | |
| tree | 5068dff10300df3c7cb60b2e53fcf1a4213bbd40 /src/main.rs | |
| parent | e9447a3c6ce3f2c3b057ae71a1949d6663bc1fe7 (diff) | |
| download | mutt-alias-auto-add-f45f00cbbe32d473deb4e23e8944a5a61e5f8e45.tar.bz2 | |
main: Ignore errors, don't write to STDERR
Well, after all that error handling I'm going to have to remove error
output. The problem was that this STDERR output interfered with the
output of the email in Mutt. When viewing a message, the screen would
become mangled (for certain messages), and I'd have to refresh (Ctrl-L)
the view.
After initially thinking this was because I was using `println!` instead
of flushing a full buffer to STDOUT, I just now realised that my output
to STDERR could be causing the problem. Sure enough, removing the STDERR
output fixed the issue.
This is certainly not ideal, so in the long term we'll probably want to
add some kind of logging mechanism so that users actually have
visibility into errors. But for now and for my own personal purposes, I
think this works. And at least it gets me around the immediate annoying
screen mangling issue.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 1129ec7..8b9c93a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ //! person has multiple email addresses. use std::env; -use std::io::{self, BufRead, Write}; +use std::io::{self, BufRead}; mod alias; @@ -42,12 +42,7 @@ fn main() { if line.starts_with("From: ") { let mut alias = Alias::new(&line); - match alias.write_to_file(&file) { - Ok(_) => continue, - Err(e @ AliasSearchError::NotFound) | Err(e @ AliasSearchError::EmailExists) => - io::stderr().write(e.to_string().as_bytes()).ok(), - Err(e) => io::stderr().write(e.to_string().as_bytes()).ok(), - }; + alias.write_to_file(&file).ok(); } } } |
