sheave_server/
invalid_uri.rs

1use std::{
2    error::Error,
3    fmt::{
4        Display,
5        Formatter,
6        Result as FormatResult
7    },
8    io::{
9        Error as IOError,
10        ErrorKind
11    }
12};
13
14/// An error that an URI in the command line option is invalid.
15#[derive(Debug)]
16pub struct InvalidUri(String);
17
18impl Display for InvalidUri {
19    fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
20        writeln!(f, "{}", self.0)
21    }
22}
23
24impl Error for InvalidUri {}
25
26/// A utility function of constructing an `InvalidUri` error.
27pub fn invalid_uri(message: String) -> IOError {
28    IOError::new(
29        ErrorKind::InvalidData,
30        InvalidUri(message)
31    )
32}