#![allow(unused)]
use {
derive_more::{Display, Error},
problemo::*,
};
#[derive(Debug, Display, Error, PartialEq)]
pub enum OperatingSystemError {
#[display("I/O")]
IO,
#[display("network")]
Network,
}
fn read_the_file(path: &str) -> Result<String, Problem> {
std::fs::read_to_string(path).via(OperatingSystemError::IO)
}
fn main() {
if let Err(problem) = read_the_file("non-existing.txt") {
if problem.has_error(&OperatingSystemError::IO) {
println!("Can't input or output!");
}
else if problem.has_error_type::<OperatingSystemError>() {
println!("Your computer is broken!");
}
}
}