Beispiel #1
0
    def process(self):
        if settings_sub.IS_DEV:
            self.html_param['dbg_print_log'] = OSAUtil.makeRequestInfo(
                self.request, '<br />', self.osa_util.init_time)

        self.html_param['url_session_callback'] = self.makeAppLinkUrl(
            UrlMaker.top(), add_frompage=False)

        self.html_param['is_dev'] = self.osa_util.is_dbg_user
        self.writeAppHtml('session_error')
Beispiel #2
0
    def makeErrorResponse(cls, django_request):
        response = HttpResponse(status=cls.get_default_status())

        try:
            info = sys.exc_info()

            ex = '%s:%s' % (str(info[0]).replace('<', '').replace('>',
                                                                  ''), info[1])
            trace_arr = [
                '%s:%s<br />- %s<br />' % (t[0], t[1], t[2])
                for t in traceback.extract_tb(info[2])
            ]

            arr = []
            arr.append('trace:<br />%s<br />error:%s' %
                       (''.join(trace_arr), ex))
            arr.append('')
            arr.append('django_request.META: %s<br />' % django_request.META)
            arr.append(
                OSAUtil.makeRequestInfo(HttpRequest(django_request),
                                        sep='<br />'))

            body = '<br />'.join(arr).replace('<br />', '\r\n')

            response.send(body)

            if settings_sub.IS_LOCAL:
                pass
            else:
                try:
                    # ここでException吐くとレスポンス返さなくなっちゃうので.
                    dir_path = settings_sub.ERR_LOG_PATH
                    open(os.path.join(dir_path, 'unknown_error'),
                         'w').write(body)
                except Exception, e:
                    response.clear()
                    response.send(str(e))
        except Exception, e:
            response.clear()
            response.send(str(e))