Actix throw error
and ( authenticated ()) // if this fails, don't continue with any other filter. and ( path ! ( "upload" )) // if this fails, continue with `b`. Let a = warp:: post () // if this fails, continue with `b`. Without rejections + recover however, it does somewhat seem like there's a gap when it comes to unified error handling? Of course, every individual route could call a function to build an error response, but having this everywhere: Maybe the annoying verbosity of warp::reject::custom should have ticked me off :smile.
Rejections seemed silly since I wouldn't want to try the entire rest of the tree just to have it fail to match.ĭespite that, I've mistakenly (apparently thanks for the clarification, the repo being small enough to watch fully has been helpful) found myself rejecting with warp::reject::custom(ApiError::Variant) so far, and looking for ApiError in a recover filter. I've only been using warp for a few weeks (tracking master pre-0.2), and I was initially relatively confused about what the proper way to deal with routes failing was. I would definitely be interested in that, though I'm not sure what it would look like. It may be worth adding some pattern to ease that? I think this is what I needed to read, I've apparently been going about this incorrectly the whole time. In that case, you'd want to construct a Reply that describes your error. If a filter is otherwise fully matched, and an error occurs in your business logic, it's probably not correct to reject with the error. Rejections are meant to say a Filter couldn't fulfill its preconditions, but maybe another Filter can.