Esempio n. 1
0
 def test_from_error_serializable(self):
     try:
         e = Exception()
         e.random = {"foo": "bar"}
         raise e
     except Exception:
         wrapped_exc = InternalError.from_error(sys.exc_info(), json.JSONEncoder)
         json.dumps(wrapped_exc.as_error_object())
Esempio n. 2
0
    def test_from_error_not_serializable(self):
        class NonSerializableObject(object):
            pass

        try:
            e = Exception()
            e.random = NonSerializableObject()
            raise e
        except Exception:
            wrapped_exc = InternalError.from_error(sys.exc_info(), json.JSONEncoder)
            json.dumps(wrapped_exc.as_error_object())
 def fake_encode(input):
     if "result" in input:
         raise InternalError("Could not parse the input data.")
     else:
         return original_encode(input)
 def custom_encode(input):
     if "result" in input and input["id"] == "foo":
         raise InternalError("Could not parse the input data.")
     else:
         return original_encode(input)