Skip to main content

oak_core/errors/
from_std.rs

1use crate::errors::{OakError, OakErrorKind};
2
3impl From<OakErrorKind> for OakError {
4    fn from(kind: OakErrorKind) -> Self {
5        Self { kind: Box::new(kind) }
6    }
7}
8
9impl From<std::io::Error> for OakError {
10    fn from(error: std::io::Error) -> Self {
11        OakErrorKind::IoError { error, source_id: None }.into()
12    }
13}
14
15impl From<std::num::ParseIntError> for OakError {
16    fn from(error: std::num::ParseIntError) -> Self {
17        OakErrorKind::ParseError { message: error.to_string() }.into()
18    }
19}
20
21impl From<std::num::ParseFloatError> for OakError {
22    fn from(error: std::num::ParseFloatError) -> Self {
23        OakErrorKind::ParseError { message: error.to_string() }.into()
24    }
25}