def set_error_handler(self, error_handler=None):
        if error_handler is None:
            if self.debug:
                deh_type = self.default_debug_error_handler_type
            else:
                deh_type = self.default_error_handler_type
            error_handler = deh_type()
        check_render_error(error_handler.render_error, self.resources)
        wsgi_wrapper = getattr(error_handler, 'wsgi_wrapper', None)
        if wsgi_wrapper is None:
            pass  # no wsgi_wrapper, no problem
        elif not callable(wsgi_wrapper):
            raise TypeError('expected error_handler.wsgi_wrapper to be'
                            ' callable or None, not %r' % (wsgi_wrapper,))
        else:
            wrapped_wsgi = wsgi_wrapper(self._dispatch_wsgi)
            try:
                check_valid_wsgi(wrapped_wsgi)
            except __HOLE__ as te:
                raise TypeError('expected valid WSGI callable from error'
                                ' handler (%r) WSGI wrapper (%r), instead'
                                ' got issue: %r'
                                % (error_handler, wsgi_wrapper, te))
            self._dispatch_wsgi = wrapped_wsgi
        self.error_handler = error_handler
dataset/ETHPy150Open mahmoud/clastic/clastic/application.py/BaseApplication.set_error_handler