-
Notifications
You must be signed in to change notification settings - Fork 1
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
return 404 if didn't find an uuid #89
return 404 if didn't find an uuid #89
Conversation
@@ -39,7 +39,7 @@ public ResponseEntity<Collection> getCollection(String id, String sortBy) throws | |||
return ResponseEntity.ok() | |||
.body(StacToCollection.convert(model.getCollections().get(0))); | |||
} else { | |||
throw new NoSuchElementException(String.format("uuid %s not found!", id)); | |||
return ResponseEntity.notFound().build(); |
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.
can you add more details to the returning message than simply 404 http status code?
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.
test also failed
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.
👌
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.
after double-checking, i found this function want to return: ResponseEntity<Colleciton>
, so i can only set body whose type is a Collection
. For not messing up this function, i think only 404 code is enough for this situation, because the client side knows the url and uuid.
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.
so cannot do something like this?
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(String.format("uuid %s not found!", id));
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.
or, having a log log.error(...)
; before returning 404 code.
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.
so you don't have to make the controller method returning type using raw ResponseEntity
.
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.
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.
can you please try, otherwise missing out what previously tried to inform.
the client side is ok, knows the uuid and the NOT_FOUND status. For the server side output, do you think adding a log.error()
is ok?
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.
yep, you can just print the log if too much hassles to deal with, I think the previous impl to get some traces for what happened should stay. I've seen animaltracking controllers always use raw ResponseEntity type for the method declaration.
@@ -39,7 +39,7 @@ public ResponseEntity<Collection> getCollection(String id, String sortBy) throws | |||
return ResponseEntity.ok() | |||
.body(StacToCollection.convert(model.getCollections().get(0))); | |||
} else { | |||
throw new NoSuchElementException(String.format("uuid %s not found!", id)); | |||
return ResponseEntity.notFound().build(); |
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.
test also failed
No description provided.