Python pyramid.httpexceptions.HTTPInternalServerError() Examples

The following are 3 code examples of pyramid.httpexceptions.HTTPInternalServerError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyramid.httpexceptions , or try the search function .
Example #1
Source File: jsonhelper.py    From TitleDB with The Unlicense 6 votes vote down vote up
def __call__(self, info):
        """
        If a schema is present, replace value with output from schema.dump(..).
        """
        original_render = super().__call__(info)

        def schema_render(value, system):
            request = system.get('request')
            if (request is not None and isinstance(getattr(request, 'render_schema', None), Schema)):
# This doesn't catch errors...
                value, errors = request.render_schema.dump(value)
# This will catch errors
#                try:
#                    value, errors = request.render_schema.dump(value)
#                except Exception:
#                    errors = True

#                if errors:
#                    raise HTTPInternalServerError(body="Serialization failed.")

            return original_render(value, system)

        return schema_render 
Example #2
Source File: app.py    From python-sensor with MIT License 5 votes vote down vote up
def please_fail(request):
    raise exc.HTTPInternalServerError("internal error") 
Example #3
Source File: pyramid_base_test.py    From opentelemetry-python with Apache License 2.0 5 votes vote down vote up
def _hello_endpoint(request):
        helloid = int(request.matchdict["helloid"])
        if helloid == 500:
            raise exc.HTTPInternalServerError()
        return Response("Hello: " + str(helloid))