Skip to content

Commit

Permalink
change response code of error to http 500
Browse files Browse the repository at this point in the history
  • Loading branch information
brussee committed May 13, 2016
1 parent d3875e0 commit fd6d876
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions Tribler/Core/Modules/restapi/my_channel_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def render_PUT(self, request):
try:
channel_id = self.session.create_channel(parameters['name'][0], parameters['description'][0], mode)
except DuplicateChannelNameError as ex:
request.setResponseCode(http.INTERNAL_SERVER_ERROR)
request.setHeader('Content-Type', 'text/json')
return json.dumps({
"error": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def verify_channel_created(body):
@deferred(timeout=10)
def test_my_channel_endpoint_create_duplicate_name_error(self):
"""
Testing whether the API returns a formatted 200 error if DuplicateChannelNameError is raised
Testing whether the API returns a formatted 500 error if DuplicateChannelNameError is raised
"""

def verify_error_message(body):
Expand All @@ -136,8 +136,8 @@ def verify_error_message(body):
}
self.session.create_channel = self.create_fake_channel_with_existing_name
self.should_check_equality = False
return self.do_request('mychannel', expected_code=200, expected_json=None, request_type='PUT',
post_data=post_data).addCallback(verify_error_message)
return self.do_request('mychannel', expected_code=500, expected_json=None, request_type='PUT',
post_data=post_data).addErrback(verify_error_message)

@deferred(timeout=10)
def test_my_channel_endpoint_create_no_name_param(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/Tribler REST API.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If an unhandled exception occurs the response will have code HTTP 500 and look l
}
}
```
If a valid request of a client caused a recoverable error the response will have code HTTP 200 and look like this:
If a valid request of a client caused a recoverable error the response will have code HTTP 500 and look like this:
```json
{
"error": {
Expand Down

0 comments on commit fd6d876

Please sign in to comment.