TeamModelledRestService - Set status code for response
3 answers
Is there a way I can set the status of the HTTP response object which
is returned when I am implementing services which use
ITeamModelledRestService interface ?
You can throw an exception:
ItemNotFoundException -> 404 Not found
IllegalArgumentException -> 400 Bad Request
StaleDataException -> 409 Conflict
TeamRepositoryException -> 500 Internal Server Error
....
Which status code would you like to set?
Regards,
Patrick
Jazz Work Item Team
It could be either 404, 409 or 500 depending on the exception caught
in service implementation code.
So you could just declare your methods in ITeamModelledRestService with
'throws TeamRepositoryException' and either don't catch the exceptions
if they are already either ItemNotFoundException (404),
StaleDataException (409) or TeamRepositoryException (500 or depending on
the actual subclass).
If you are catching other exceptions, you can throw one of the above to
get the corresponding HTTP status code.
HTH,
Patrick
Jazz Work Item Team