Remove various usage of sys.exc_info()
Change-Id: I7454264b82e808c68dd182e7ce43db756651a00b
This commit is contained in:
parent
15c05263c3
commit
1c37ea475e
@ -192,8 +192,7 @@ class WSRoot(object):
|
||||
# TODO make sure result type == a._wsme_definition.return_type
|
||||
return protocol.encode_result(context, result)
|
||||
|
||||
except Exception:
|
||||
e = sys.exc_info()[1]
|
||||
except Exception as e:
|
||||
infos = wsme.api.format_exception(sys.exc_info(), self._debug)
|
||||
if isinstance(e, ClientSideError):
|
||||
request.client_errorcount += 1
|
||||
@ -233,8 +232,7 @@ class WSRoot(object):
|
||||
try:
|
||||
msg = None
|
||||
protocol = self._select_protocol(request)
|
||||
except Exception:
|
||||
e = sys.exc_info()[1]
|
||||
except Exception as e:
|
||||
msg = ("Error while selecting protocol: %s" % str(e))
|
||||
log.exception(msg)
|
||||
protocol = None
|
||||
@ -339,8 +337,7 @@ class WSRoot(object):
|
||||
return html_body % dict(
|
||||
css=formatter.get_style_defs(),
|
||||
content=highlight(content, lexer, formatter).encode('utf8'))
|
||||
except Exception:
|
||||
e = sys.exc_info()[1]
|
||||
except Exception as e:
|
||||
log.warning(
|
||||
"Could not pygment the content because of the following "
|
||||
"error :\n%s" % e)
|
||||
|
@ -4,7 +4,6 @@ import unittest
|
||||
import warnings
|
||||
import datetime
|
||||
import decimal
|
||||
import sys
|
||||
import six
|
||||
|
||||
from six import u, b
|
||||
@ -22,8 +21,7 @@ binarysample = b('\x00\xff\x43')
|
||||
|
||||
try:
|
||||
1 / 0
|
||||
except ZeroDivisionError:
|
||||
e = sys.exc_info()[1]
|
||||
except ZeroDivisionError as e:
|
||||
zerodivisionerrormsg = str(e)
|
||||
|
||||
|
||||
@ -379,8 +377,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
res = self.call('invalid_function')
|
||||
print(res)
|
||||
assert "No error raised"
|
||||
except CallException:
|
||||
e = sys.exc_info()[1]
|
||||
except CallException as e:
|
||||
self.assertEquals(e.faultcode, 'Client')
|
||||
self.assertEquals(e.faultstring.lower(),
|
||||
u('unknown function name: invalid_function'))
|
||||
@ -390,9 +387,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
res = self.call('witherrors/divide_by_zero')
|
||||
print(res)
|
||||
assert "No error raised"
|
||||
except CallException:
|
||||
e = sys.exc_info()[1]
|
||||
print(e)
|
||||
except CallException as e:
|
||||
self.assertEquals(e.faultcode, 'Server')
|
||||
self.assertEquals(e.faultstring, zerodivisionerrormsg)
|
||||
assert e.debuginfo is not None
|
||||
@ -403,9 +398,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
res = self.call('witherrors/divide_by_zero')
|
||||
print(res)
|
||||
assert "No error raised"
|
||||
except CallException:
|
||||
e = sys.exc_info()[1]
|
||||
print(e)
|
||||
except CallException as e:
|
||||
self.assertEquals(e.faultcode, 'Server')
|
||||
self.assertEquals(e.faultstring, zerodivisionerrormsg)
|
||||
assert e.debuginfo is None
|
||||
@ -649,9 +642,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
r = self.call('argtypes/setdatetime')
|
||||
print(r)
|
||||
assert "No error raised"
|
||||
except CallException:
|
||||
e = sys.exc_info()[1]
|
||||
print(e)
|
||||
except CallException as e:
|
||||
self.assertEquals(e.faultcode, 'Client')
|
||||
self.assertEquals(e.faultstring, u('Missing argument: "value"'))
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
# encoding=utf8
|
||||
|
||||
from six import b
|
||||
import sys
|
||||
|
||||
import unittest
|
||||
import webtest
|
||||
@ -107,8 +106,7 @@ class TestController(unittest.TestCase):
|
||||
try:
|
||||
list(scan_api(r))
|
||||
assert False, "ValueError not raised"
|
||||
except ValueError:
|
||||
e = sys.exc_info()[1]
|
||||
except ValueError as e:
|
||||
assert str(e).startswith("Path is too long")
|
||||
|
||||
def test_handle_request(self):
|
||||
|
@ -1,5 +1,4 @@
|
||||
import unittest
|
||||
import sys
|
||||
import six
|
||||
|
||||
from wsme import types
|
||||
@ -180,8 +179,7 @@ class TestTypes(unittest.TestCase):
|
||||
try:
|
||||
obj.a = 'v3'
|
||||
assert False, 'ValueError was not raised'
|
||||
except ValueError:
|
||||
e = sys.exc_info()[1]
|
||||
except ValueError as e:
|
||||
assert str(e) == \
|
||||
"a: Value 'v3' is invalid (should be one of: v1, v2)", e
|
||||
|
||||
|
@ -340,8 +340,7 @@ class wsattr(object):
|
||||
def __set__(self, instance, value):
|
||||
try:
|
||||
value = validate_value(self.datatype, value)
|
||||
except ValueError:
|
||||
e = sys.exc_info()[1]
|
||||
except ValueError as e:
|
||||
raise ValueError("%s: %s" % (self.name, e))
|
||||
dataholder = self._get_dataholder(instance)
|
||||
if value is Unset:
|
||||
|
@ -1,7 +1,6 @@
|
||||
import decimal
|
||||
import datetime
|
||||
import base64
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
@ -318,8 +317,7 @@ class TestSOAP(wsme.tests.protocol.ProtocolTestCase):
|
||||
print(kw)
|
||||
try:
|
||||
return fromsuds(_rt, m(**kw))
|
||||
except suds.WebFault:
|
||||
exc = sys.exc_info()[1]
|
||||
except suds.WebFault as exc:
|
||||
raise wsme.tests.protocol.CallException(
|
||||
exc.fault.faultcode,
|
||||
exc.fault.faultstring,
|
||||
|
Loading…
Reference in New Issue
Block a user