From: John Griffith Date: Tue, 13 Oct 2015 03:44:09 +0000 (-0600) Subject: Change default Exception code to 500 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9a7cbe540c94d54194194f4747a52b8211f6372e;p=openstack-build%2Fcinder-build.git Change default Exception code to 500 As a part of the fix for LP#1505153, the invalid response of 0 was changed to 400 to fix a running issue with the new version of WebOb. It was pointed out after the fact however that a 500 might be more appropriate here. Additionally, other projects have implemented a 500 as the default so for the sake of consistency we should consider doing the same. This patch just changes the 400 to a 500 as the default code. Change-Id: Ie486dc49c927f9b50f07c1fc562e89c090924a40 Closes-Bug: #1505488 --- diff --git a/cinder/exception.py b/cinder/exception.py index 2fed70b0b..ef50bd67b 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -48,7 +48,7 @@ CONF.register_opts(exc_log_opts) class ConvertedException(webob.exc.WSGIHTTPException): - def __init__(self, code=400, title="", explanation=""): + def __init__(self, code=500, title="", explanation=""): self.code = code # There is a strict rule about constructing status line for HTTP: # '...Status-Line, consisting of the protocol version followed by a diff --git a/cinder/tests/unit/test_exception.py b/cinder/tests/unit/test_exception.py index b8591b435..76d75a027 100644 --- a/cinder/tests/unit/test_exception.py +++ b/cinder/tests/unit/test_exception.py @@ -107,7 +107,7 @@ class CinderConvertedExceptionTestCase(test.TestCase): def test_default_args(self): exc = exception.ConvertedException() self.assertNotEqual('', exc.title) - self.assertEqual(400, exc.code) + self.assertEqual(500, exc.code) self.assertEqual('', exc.explanation) def test_standard_status_code(self):