Closed DCjanus closed 6 years ago
there something like
fn do_something() -> Option<Info> { // some code may return None } fn custom_response() -> Response { // some code build custom response }
with this commit, you could write code like
fn with_custom_response_error(req: &mut Request, res: Response) -> SapperResult<Response> { let info = do_something().ok_or(SapperError::CustomResponse(custom_response()))?; // success or return custom response immediately // some code Ok(res) }
without this commit, you have to write code like
fn without_custom_response_error(req: &mut Request, res: Response) -> SapperResult<Response> { if let Some(info) = do_something() { // some code Ok(res) } else { Ok(custom_response()) } }
Hope to be merged soon @daogangtang @driftluo
With custom error, there will be more option for middleware.
there something like
with this commit, you could write code like
without this commit, you have to write code like