summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-12-25 13:38:41 +0100
committerMatthias Beyer <mail@beyermatthias.de>2019-12-26 11:37:08 +0100
commitec030b5034bf75a30b8a23f2c573da0fc2d3f429 (patch)
tree9c4334e14a3fd83a2fec89c53e0f477c869e4632
parent60298dd04a2c8fe48bc58ef1d5430538b1996b46 (diff)
downloadimag-ec030b5034bf75a30b8a23f2c573da0fc2d3f429.tar.gz
imag-ec030b5034bf75a30b8a23f2c573da0fc2d3f429.tar.xz
-rw-r--r--lib/core/libimagrt/src/application.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/core/libimagrt/src/application.rs b/lib/core/libimagrt/src/application.rs
index 74ad4b68..e1de1fe2 100644
--- a/lib/core/libimagrt/src/application.rs
+++ b/lib/core/libimagrt/src/application.rs
@@ -37,34 +37,24 @@ macro_rules! simple_imag_application_binary {
extern crate failure;
extern crate $application_library;
- use failure::{Error, Fallible as Result};
-
+ use failure::{Error, Fallible as Result, ResultExt};
+
fn main() {
use libimagerror::trace::MapErrTrace;
use libimagrt::application::ImagApplication;
use libimagrt::setup::generate_runtime_setup;
use $application_library::$application_implementor;
-
+
let version = make_imag_version!();
let rt = generate_runtime_setup($application_implementor::name(),
&version,
$application_implementor::description(),
$application_implementor::build_cli);
- // The error context must have a 'static lifetime
- // Therefore, the easiest, safe, but hacky way to achieve this
- // is to allocate a string, which is then forgotten to
- // leak memory and return it's contents as a &'static str
- // Because this is the very end of the application and only
- // happens once, it should have no impact whatsoever
- let error_context: &'static str = Box::leak(
- format!("Failed to run {}", $application_implementor::name())
- .into_boxed_str()
- );
$application_implementor::run(rt)
- .map_err(|e| e.context(error_context))
- .map_err(Error::from)
- .map_err_trace_exit_unwrap();
+ .context(format!("Failed to run {}", $application_implementor::name()))
+ .map_err(Error::from)
+ .map_err_trace_exit_unwrap();
}
};
}