VmErr classifier for the ABI boundary. */
(e: &VmErr)
| 7 | |
| 8 | /* VmErr classifier for the ABI boundary. */ |
| 9 | pub(super) fn err_to_kind(e: &VmErr) -> ErrorKind { |
| 10 | match e { |
| 11 | VmErr::Type(_) | VmErr::TypeMsg(_) => ErrorKind::Type, |
| 12 | VmErr::Value(_) => ErrorKind::Value, |
| 13 | VmErr::Runtime(_) => ErrorKind::Runtime, |
| 14 | VmErr::Attribute(_) | VmErr::Name(_) => ErrorKind::Attribute, |
| 15 | VmErr::Raised(s) => { |
| 16 | if s.starts_with("ValueError") { ErrorKind::Value } |
| 17 | else if s.starts_with("IndexError") { ErrorKind::Index } |
| 18 | else if s.starts_with("KeyError") { ErrorKind::Key } |
| 19 | else { ErrorKind::Runtime } |
| 20 | } |
| 21 | _ => ErrorKind::Runtime, |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | pub(super) fn stash_error(e: VmErr) { |
| 26 | let kind = err_to_kind(&e); |