diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-07-11 10:28:54 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-07-30 10:14:53 +0300 |
commit | 7af18792fa7e783f391910836c2615f6d590b992 (patch) | |
tree | 4be2a0a63b6b8615b0bd8200c36301b899f48912 /src | |
parent | 60b5a9a313bec0a6e475f9c16380977ed1c7eafb (diff) | |
download | subplot-7af18792fa7e783f391910836c2615f6d590b992.tar.gz |
chore: handle write! errors
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings.rs | 2 | ||||
-rw-r--r-- | src/error.rs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/bindings.rs b/src/bindings.rs index b596c84..8c33cc4 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -853,7 +853,7 @@ fn regex_from_simple_pattern( } }; - write!(r, r"(?P<{}>{})", name, kind.regex_str()).unwrap(); + write!(r, r"(?P<{}>{})", name, kind.regex_str()).map_err(SubplotError::StringFormat)?; end = m.end(); } let after = &pattern[end..]; diff --git a/src/error.rs b/src/error.rs index a42298d..8236faf 100644 --- a/src/error.rs +++ b/src/error.rs @@ -309,6 +309,10 @@ pub enum SubplotError { /// UTF8 conversion error. #[error(transparent)] Utf8Error(#[from] std::str::Utf8Error), + + /// String formatting failed. + #[error("Failed in string formattiing: {0}")] + StringFormat(std::fmt::Error), } impl SubplotError { |