use pyo3::{exceptions::PyRuntimeError, PyErr};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum PyMiddlewareError {
#[error("`next` is called multiple times")]
NextAlreadyCalled,
#[error("request is accessed after `next` is called")]
RequestGone,
#[error("response is called after it is returned")]
ResponseGone,
}
impl From<PyMiddlewareError> for PyErr {
fn from(err: PyMiddlewareError) -> PyErr {
PyRuntimeError::new_err(err.to_string())
}
}