MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / error_from_kind

Function error_from_kind

compiler/src/main/errors.rs:32–43  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

30
31/* Inverse of `err_to_kind`: rebuilds a `VmErr` from (kind, msg). Exhaustive over `ErrorKind` so new variants can't slip into `Raised`. */
32pub(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}

Callers 2

set_host_error_by_idFunction · 0.85
make_native_bindingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected