Conversation
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (71.95%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #517 +/- ##
============================================
+ Coverage 61.26% 72.52% +11.25%
============================================
Files 57 57
Lines 2685 2300 -385
============================================
+ Hits 1645 1668 +23
+ Misses 1040 632 -408 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ae6a238 to
35b9939
Compare
35b9939 to
b125b1b
Compare
c82a0dc to
edd2b50
Compare
c904a8f to
f6471c8
Compare
asuresh-code
left a comment
There was a problem hiding this comment.
Reviewed just the implementation, looks good, most of the suggestions were around documentation/comments.
| if parent_id and not self.get(parent_id, session=session): | ||
| raise MissingRecordError(f"No parent catalogue category found with ID: {parent_id}") |
There was a problem hiding this comment.
Since this method no longer directly raises the MissingRecordError, I think it can be removed from the docstrings.
There was a problem hiding this comment.
Yeah I wasn't sure what to do around those, my initial instinct was to remove them, but when I tried to look it up I found people suggesting it can also make sense to mention those that are likely to be raised/are uncaught.
https://stackoverflow.com/questions/33262919/should-the-docstring-only-contain-the-exceptions-that-are-explicitly-raised-by-a
https://stackoverflow.com/questions/58635016/should-docstring-contain-a-raises-statement-if-the-error-is-handled-in-the-cod
It would be nice to remove them so we don't need to duplicate them though...
There was a problem hiding this comment.
Yeah I could see why it would be beneficial to mention exceptions raised further down the chain. If it was done here, then I think it should be replicated in other functions as well.
My only concern is that in some functions in the router level there could be 8 or 9 exceptions listed. Seems like a lot, but on the other hand might be useful to see all of the exceptions a method could throw, especially at the router level, so you could see everything associated with the operation.
| if parent_id and not self.get(parent_id, session=session): | ||
| raise MissingRecordError(f"No parent catalogue category found with ID: {parent_id}") |
There was a problem hiding this comment.
MissingReocrdError can be removed from docstrings.
| stored_catalogue_category = self.get(catalogue_category_id) | ||
| if not stored_catalogue_category: | ||
| raise MissingRecordError(f"No catalogue category found with ID: {catalogue_category_id}") | ||
|
|
There was a problem hiding this comment.
Can remove MissingRecordError from Docstings.
6d29c1d to
bb41ed1
Compare
| ) | ||
| catalogue_category = self.get(str(result.inserted_id), session=session) | ||
| return catalogue_category | ||
| return self.get(str(result.inserted_id), session=session) |
There was a problem hiding this comment.
If self.get raises a MissingRecordError, then 404 - Catalogue category not found will be returned as the response. Without these changes, 500 - Something went wrong is returned because of the unhandled exception that occurs when .model_dump() is done in the router due to the value returned being None. While I am not sure whether not handling this case is the right thing to do but I believe returning 500 in this case is better than 404.
Description
Attempts to refactor error handling to match a similar method to object-storage-api.
Notes
Testing instructions
Add a set up instructions describing how the reviewer should test the code
Agile board tracking
Closes #74