5 ms·
Cool article on how to abstract things in Rust. I must admit, I usually write the "bad rust application". Total nitpick: For `CreateAuthorError::Duplicate`, I
by Kostarrr 2y ago
Cool article on how to abstract things in Rust. I must admit, I usually write the "bad rust application".
Total nitpick: For `CreateAuthorError::Duplicate`, I would return a 409 Conflict, not a 422 Unprocessable Entity. When I see a 422 I think utf-8 encoding error or maybe some bad json, not a duplicate key in a database.
- slau 2y agoI agree that a duplicate key problem is 409. However I disagree that 422 is for encoding issues. Quite the contrary, 422 specifically says that “the server understood the content type of the request entity, and the syntax of the request entity was correct, but it was unable to process the contained instructions.”[1] So it’s more “your request didn’t make logical sense” more than “your request was missing a closing bracket”. That’s just a 400. [1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422