Fix Masakari API to properly return error codes
Change-Id: I538b9b143c868d9419709356daf0ffc48e2f0df9 Closes-Bug: #1932194
This commit is contained in:
parent
4e84d3a9c9
commit
5c6fd44504
masakari
releasenotes/notes
@ -44,7 +44,7 @@ CONF = masakari.conf.CONF
|
||||
|
||||
class ConvertedException(webob.exc.WSGIHTTPException):
|
||||
def __init__(self, code, title="", explanation=""):
|
||||
self.code = code
|
||||
self.code = int(code)
|
||||
# There is a strict rule about constructing status line for HTTP:
|
||||
# '...Status-Line, consisting of the protocol version followed by a
|
||||
# numeric status code and its associated textual phrase, with each
|
||||
|
@ -253,8 +253,9 @@ class ResourceTest(MicroversionedTest):
|
||||
@extensions.expected_errors(HTTPStatus.BAD_REQUEST)
|
||||
def create(self, req, body):
|
||||
if expected_body != body:
|
||||
msg = "The request body invalid"
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
raise exception.ConvertedException(
|
||||
code=HTTPStatus.BAD_REQUEST,
|
||||
explanation="The request body invalid")
|
||||
return "success"
|
||||
# verify the method: POST
|
||||
app = fakes.TestRouter(Controller())
|
||||
|
6
releasenotes/notes/bug-1932194-2b721860bbc26819.yaml
Normal file
6
releasenotes/notes/bug-1932194-2b721860bbc26819.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes Masakari API to properly return error codes for invalid requests
|
||||
to the user instead of 500.
|
||||
`LP#1932194 <https://launchpad.net/bugs/1932194>`__
|
Loading…
Reference in New Issue
Block a user