mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
wbexception: remove unused status in WbException, set default error for
any uncaught exception to 500, instead of 400
This commit is contained in:
parent
7610d9deb7
commit
8449647c5f
@ -14,7 +14,7 @@ class TestOkApp:
|
|||||||
|
|
||||||
class TestErrApp:
|
class TestErrApp:
|
||||||
def __call__(self, env):
|
def __call__(self, env):
|
||||||
raise Exception('Test Error')
|
raise Exception('Test Unexpected Error')
|
||||||
|
|
||||||
class TestCustomErrApp:
|
class TestCustomErrApp:
|
||||||
def __call__(self, env):
|
def __call__(self, env):
|
||||||
@ -41,8 +41,8 @@ def test_err_app():
|
|||||||
testapp = webtest.TestApp(the_app)
|
testapp = webtest.TestApp(the_app)
|
||||||
resp = testapp.get('/abc', expect_errors=True)
|
resp = testapp.get('/abc', expect_errors=True)
|
||||||
|
|
||||||
assert resp.status_int == 400
|
assert resp.status_int == 500
|
||||||
assert '400 Bad Request Error: Test Error' in resp.body
|
assert '500 Internal Server Error Error: Test Unexpected Error' in resp.body
|
||||||
|
|
||||||
def test_custom_err_app():
|
def test_custom_err_app():
|
||||||
the_app = init_app(initer(TestCustomErrApp), load_yaml=False)
|
the_app = init_app(initer(TestCustomErrApp), load_yaml=False)
|
||||||
|
@ -118,7 +118,7 @@ class WSGIApp(object):
|
|||||||
if hasattr(exc, 'status'):
|
if hasattr(exc, 'status'):
|
||||||
status = exc.status()
|
status = exc.status()
|
||||||
else:
|
else:
|
||||||
status = '400 Bad Request'
|
status = '500 Internal Server Error'
|
||||||
|
|
||||||
if hasattr(exc, 'url'):
|
if hasattr(exc, 'url'):
|
||||||
err_url = exc.url
|
err_url = exc.url
|
||||||
|
@ -6,8 +6,9 @@ class WbException(Exception):
|
|||||||
Exception.__init__(self, msg)
|
Exception.__init__(self, msg)
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
def status(self):
|
# Default Error Code
|
||||||
return '500 Internal Server Error'
|
# def status(self):
|
||||||
|
# return '500 Internal Server Error'
|
||||||
|
|
||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user