Skip to main content

ocaml_interop/
error.rs

1// Copyright (c) Viable Systems and TezEdge Contributors
2// SPDX-License-Identifier: MIT
3
4use crate::mlvalues::{MAX_FIXNUM, MIN_FIXNUM};
5use core::fmt;
6
7#[derive(Debug)]
8pub enum OCamlFixnumConversionError {
9    InputTooBig(i64),
10    InputTooSmall(i64),
11}
12
13impl fmt::Display for OCamlFixnumConversionError {
14    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15        match self {
16            OCamlFixnumConversionError::InputTooBig(n) => write!(
17                f,
18                "Input value doesn't fit in OCaml fixnum n={n} > MAX_FIXNUM={MAX_FIXNUM}",
19            ),
20            OCamlFixnumConversionError::InputTooSmall(n) => write!(
21                f,
22                "Input value doesn't fit in OCaml fixnum n={n} < MIN_FIXNUM={MIN_FIXNUM}",
23            ),
24        }
25    }
26}