1
0
Fork 0

Introduce an nih_error!() macro for fatal errors

This commit is contained in:
Robbert van der Helm 2022-06-14 16:28:54 +02:00
parent 3d5f44764e
commit e2099ec16c
4 changed files with 15 additions and 6 deletions

View file

@ -21,6 +21,15 @@ macro_rules! nih_log {
}
pub use nih_log;
/// Similar to `nih_log!()`, more scream-y. Used for printing fatal errors.
#[macro_export]
macro_rules! nih_error {
($($args:tt)*) => (
$crate::log::error!($($args)*)
);
}
pub use nih_error;
/// The same as `nih_log!()`, but with source and thread information. Like the
/// `nih_debug_assert*!()` macros, this is only shown when compiling in debug mode.
#[macro_export]

View file

@ -80,7 +80,7 @@ pub fn nih_export_standalone_with_args<P: Plugin, Args: IntoIterator<Item = Stri
config::BackendType::Jack => match backend::Jack::new(config.clone()) {
Ok(backend) => run_wrapper::<P, _>(backend, config),
Err(err) => {
nih_log!("{:#}", err);
nih_error!("Could not initialize the JACK backend: {:#}", err);
false
}
},
@ -112,10 +112,10 @@ fn run_wrapper<P: Plugin, B: Backend>(backend: B, config: WrapperConfig) -> bool
fn print_error(error: WrapperError, config: &WrapperConfig) {
match error {
WrapperError::IncompatibleConfig => {
eprintln!("The plugin does not support the {} channel input and {} channel output configuration", config.input_channels, config.output_channels);
nih_error!("The plugin does not support the {} channel input and {} channel output configuration", config.input_channels, config.output_channels);
}
WrapperError::InitializationFailed => {
eprintln!("The plugin failed to initialize");
nih_error!("The plugin failed to initialize");
}
}
}

View file

@ -77,7 +77,7 @@ impl Jack {
/// Initialize the JACK backend. Returns an error if this failed for whatever reason.
pub fn new(config: WrapperConfig) -> Result<Self> {
// TODO: Actually implement the JACK backend
anyhow::bail!("Could not initialize JACK backend")
anyhow::bail!("Not yet implemented")
// Ok(Self { config })
}
}

View file

@ -388,8 +388,8 @@ impl<P: Plugin, B: Backend> Wrapper<P, B> {
},
&mut self.make_process_context(transport),
) {
eprintln!("The plugin returned an error while processing:");
eprintln!("{}", err);
nih_error!("The plugin returned an error while processing:");
nih_error!("{}", err);
let push_successful = gui_task_sender.send(GuiTask::Close).is_ok();
nih_debug_assert!(