1use std::{error::Error, fmt};
2
3#[derive(Debug)]
4pub struct VMError {
5 msg: String,
6}
7
8impl fmt::Display for VMError {
9 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10 write!(f, "{}", self.msg)
11 }
12}
13
14impl Error for VMError {
15 fn description(&self) -> &str {
16 &self.msg
17 }
18}
19
20impl From<fvm_ipld_hamt::Error> for VMError {
21 fn from(h_err: fvm_ipld_hamt::Error) -> Self {
22 vm_err(h_err.to_string().as_str())
23 }
24}
25
26pub fn vm_err(msg: &str) -> VMError {
27 VMError { msg: msg.to_string() }
28}