| 3 | |
| 4 | namespace LIEF::py { |
| 5 | void init_errors(nb::module_& m) { |
| 6 | nb::class_<ok_t>(m, "ok_t", |
| 7 | R"delim( |
| 8 | Opaque value returned when a **void** function |
| 9 | is executed successfully. |
| 10 | )delim") |
| 11 | .def("__bool__", [] (const ok_t&) { return true; }); |
| 12 | |
| 13 | nb::class_<ok_error_t>(m, "ok_error_t", |
| 14 | R"delim( |
| 15 | Return either: :class:`~.ok_t` (success) or :class:`~.lief_errors` (error) |
| 16 | )delim") |
| 17 | .def_prop_ro("is_error", [] (const ok_error_t& val) { return !val.has_value(); }) |
| 18 | .def_prop_ro("is_value", [] (const ok_error_t& val) { return val.has_value(); }) |
| 19 | .def_prop_ro("error", [] (const ok_error_t& val) { return val.error(); }) |
| 20 | .def_prop_ro("value", [] (const ok_error_t& val) { return val.value(); }) |
| 21 | .def("__bool__", [] (const ok_error_t& val) { return val.has_value(); }); |
| 22 | |
| 23 | |
| 24 | nb::enum_<lief_errors>(m, "lief_errors", R"delim( |
| 25 | Enum class which represents an error generated by LIEF's functions |
| 26 | )delim") |
| 27 | .value("read_error", lief_errors::read_error) |
| 28 | .value("not_found", lief_errors::not_found) |
| 29 | .value("not_implemented", lief_errors::not_implemented) |
| 30 | .value("not_supported", lief_errors::not_supported) |
| 31 | .value("corrupted", lief_errors::corrupted) |
| 32 | .value("conversion_error", lief_errors::conversion_error) |
| 33 | .value("read_out_of_bound", lief_errors::read_out_of_bound) |
| 34 | .value("asn1_bad_tag", lief_errors::asn1_bad_tag) |
| 35 | .value("file_error", lief_errors::file_error) |
| 36 | .value("file_format_error", lief_errors::file_format_error) |
| 37 | .value("parsing_error", lief_errors::parsing_error) |
| 38 | .value("build_error", lief_errors::build_error) |
| 39 | .value("data_too_large", lief_errors::data_too_large) |
| 40 | .value("require_extended_version", lief_errors::require_extended_version) |
| 41 | ; |
| 42 | } |
| 43 | } |