Inverse of `err_to_kind`: rebuilds a `VmErr` from (kind, msg). Exhaustive over `ErrorKind` so new variants can't slip into `Raised`. */
(kind: u32, msg: String)
| 30 | |
| 31 | /* Inverse of `err_to_kind`: rebuilds a `VmErr` from (kind, msg). Exhaustive over `ErrorKind` so new variants can't slip into `Raised`. */ |
| 32 | pub(super) fn error_from_kind(kind: u32, msg: String) -> VmErr { |
| 33 | match ErrorKind::from_u32(kind) { |
| 34 | Some(ErrorKind::Type) => VmErr::TypeMsg(msg), |
| 35 | Some(ErrorKind::Value) => VmErr::Raised(s!("ValueError: ", str &msg)), |
| 36 | Some(ErrorKind::Runtime) => VmErr::Raised(s!("RuntimeError: ", str &msg)), |
| 37 | Some(ErrorKind::Attribute) => VmErr::Attribute(msg), |
| 38 | Some(ErrorKind::Index) => VmErr::Raised(s!("IndexError: ", str &msg)), |
| 39 | Some(ErrorKind::Key) => VmErr::Raised(s!("KeyError: ", str &msg)), |
| 40 | // Custom kinds carry the user-defined class name in `msg` (`<ClassName>: <text>`); pass through unchanged. |
| 41 | Some(ErrorKind::Custom) | None => VmErr::Raised(msg), |
| 42 | } |
| 43 | } |
no outgoing calls
no test coverage detected