Expand description
This attribute proc macro should be applied to main functions of the form
main() -> Result<(), Box<dyn Error>>; it wraps the returned value in a
newtype which implements Termination and displays the returned error via
error!. This macro exists purely for convenience.
Your create needs the try_trait and termination_trait_lib features.
For example:
#![feature(try_trait)]
#![feature(termination_trait_lib)]
use std::error::Error;
use std::io::ErrorKind;
#[macro_use]
extern crate log;
extern crate fern;
extern crate log_termination;
use log_termination::log_termination;
#[log_termination]
fn main() -> Result<(), Box<dyn Error>> {
fern::Dispatch::new()
.format(|o, m, r| { o.finish(format_args!(
"[{}:{}] {} {}: {}",
r.file().unwrap(),
r.line().unwrap(),
chrono::Local::now().format("%F %T"),
r.level(),
m
))})
.level(log::LevelFilter::Error)
.chain(std::io::stderr())
.apply()?;
return Err(Box::new(std::io::Error::new(ErrorKind::Other, "SNAFU")));
// This code is valid, but unreachable:
//Ok(())
}