artichoke_backend/extn/core/kernel/
integer.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use scolapasta_int_parse::InvalidRadixExceptionKind;

use crate::extn::prelude::*;

impl<'a> From<scolapasta_int_parse::Error<'a>> for Error {
    fn from(err: scolapasta_int_parse::Error<'a>) -> Self {
        use scolapasta_int_parse::Error::{Argument, Radix};

        match err {
            Argument(err) => {
                let message = err.to_string();
                ArgumentError::from(message).into()
            }
            Radix(err) => match err.exception_kind() {
                InvalidRadixExceptionKind::ArgumentError => {
                    let message = err.to_string();
                    ArgumentError::from(message).into()
                }
                InvalidRadixExceptionKind::RangeError => {
                    let message = err.to_string();
                    RangeError::from(message).into()
                }
            },
        }
    }
}