-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed error handling for bookmarks manager #137
Conversation
internal/bookmarks/manager.go
Outdated
iUserId, _ := strconv.Atoi(userId) | ||
dbBookmarks = m.DbClient.GetBookmarksByUserID(iUserId) | ||
iUserId, err := strconv.Atoi(userId) | ||
if (err != nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont need to wrap this, normal to just do
if err != nil {
stuff;
}
internal/bookmarks/manager.go
Outdated
iUserId, err := strconv.Atoi(userId) | ||
if (err != nil) { | ||
log.Printf("%v", err) | ||
writeStatus(w, http.StatusBadRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a case where we can update the flow to provide an error message json body response
internal/bookmarks/manager.go
Outdated
} | ||
|
||
dbBookmark := m.DbClient.GetBookmarkByID(id) | ||
dbBookmark, err := m.DbClient.GetBookmarkByID(id) | ||
if (err != nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to log the error here too, just the same flow as other cases
internal/bookmarks/manager.go
Outdated
iUserId, err := strconv.Atoi(userId) | ||
if (err != nil) { | ||
log.Printf("%v", err) | ||
writeStatus(w, http.StatusBadRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a test for any 400 cases
internal/db/manager.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, we do want to bubble up errors, it was a mistake of me to not do that originally
Updated PR with responses to my comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, and thanks, @lgarofalo, for pushing up a commit to create a common Error struct for returning error responses with JSON bodies!
No description provided.