in src/mlio-py/mlio/core/error.cc [130:215]
void register_exceptions(py::module &m)
{
// clang-format off
PyObject *py_mlio_error = register_exception<Mlio_error>(
m, "MLIOError", ::PyExc_RuntimeError);
PyObject *py_stream_error = register_exception<Stream_error>(
m, "StreamError", py_mlio_error);
register_exception<Inflate_error>(
m, "InflateError", py_stream_error);
PyObject *py_record_error = register_exception<Record_error>(
m, "RecordError", py_mlio_error);
PyObject *py_corrupt_record_error = register_exception<Corrupt_record_error>(
m, "CorruptRecordError", py_record_error);
register_exception<Corrupt_header_error>(
m, "CorruptHeaderError", py_corrupt_record_error);
register_exception<Corrupt_footer_error>(
m, "CorruptFooterError", py_corrupt_record_error);
register_exception<Record_too_large_error>(
m, "RecordTooLargeError", py_record_error);
PyObject *py_data_reader_error = register_exception<Data_reader_error>(
m, "DataReaderError", py_mlio_error);
register_exception<Schema_error>(
m, "SchemaError", py_data_reader_error);
register_exception<Invalid_instance_error>(
m, "InvalidInstanceError", py_data_reader_error);
register_exception<Not_supported_error>(
m, "NotSupportedError", py_mlio_error);
// clang-format on
// NOLINTNEXTLINE
py::register_exception_translator([](std::exception_ptr ptr) {
if (!ptr) {
return;
}
try {
std::rethrow_exception(ptr);
}
catch (const Not_supported_error &e) {
set_error(e, "NotSupportedError");
}
catch (const Invalid_instance_error &e) {
set_error(e, "InvalidInstanceError");
}
catch (const Schema_error &e) {
set_error(e, "SchemaError");
}
catch (const Data_reader_error &e) {
set_error(e, "DataReaderError");
}
catch (const Record_too_large_error &e) {
set_error(e, "RecordTooLargeError");
}
catch (const Corrupt_footer_error &e) {
set_error(e, "CorruptFooterError");
}
catch (const Corrupt_header_error &e) {
set_error(e, "CorruptHeaderError");
}
catch (const Corrupt_record_error &e) {
set_error(e, "CorruptRecordError");
}
catch (const Record_error &e) {
set_error(e, "RecordError");
}
catch (const Inflate_error &e) {
set_error(e, "InflateError");
}
catch (const Stream_error &e) {
set_error(e, "StreamError");
}
catch (const Mlio_error &e) {
set_error(e, "MLIOError");
}
catch (const std::system_error &e) {
set_system_error(e);
}
});
}