use std::io::{self, Write};
pub fn show_error_dialog(title: &str, message: &str) {
let _ = write_error(&mut io::stderr().lock(), title, message);
#[cfg(target_os = "macos")]
crate::macos::alert(title, message);
#[cfg(target_os = "windows")]
crate::windows::message_box(title, message);
}
fn write_error(out: &mut impl Write, title: &str, message: &str) -> io::Result<()> {
writeln!(out, "{title}: {message}")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_message_follows_the_title_on_one_line() {
let mut out = Vec::new();
write_error(&mut out, "Sandbox", "could not open the window").expect("write to a Vec");
assert_eq!(out, b"Sandbox: could not open the window\n");
}
}