use prost_reflect::{prost::DecodeError, DescriptorError}; use pyo3::{exceptions::PyRuntimeError, PyErr}; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { #[error("Given object is not a valid betterproto message.")] NoBetterprotoMessage(#[from] PyErr), #[error("Unsupported type `{0}`.")] UnsupportedType(String), #[error("Error on proto registration")] FailedToRegisterDescriptor(#[from] DescriptorError), #[error("The given binary data does not match the protobuf schema.")] FailedToDecode(#[from] DecodeError), } pub type Result = core::result::Result; impl From for PyErr { fn from(value: Error) -> Self { PyRuntimeError::new_err(value.to_string()) } }