Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Commit

Permalink
Correctly create an issue when an exception is raised
Browse files Browse the repository at this point in the history
  • Loading branch information
cnorthwood committed Nov 9, 2010
1 parent f42ce3c commit b89f095
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.pyc
build
15 changes: 9 additions & 6 deletions django_jira/middleware.py
@@ -1,9 +1,10 @@
import traceback import traceback
import hashlib import hashlib
import sys


from django.conf import settings from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed from django.core.exceptions import MiddlewareNotUsed
import SOAPpy import suds.client


class JiraExceptionReporterMiddleware: class JiraExceptionReporterMiddleware:


Expand All @@ -23,10 +24,10 @@ def __init__(self):
settings.JIRA_ISSUE_DEFAULTS settings.JIRA_ISSUE_DEFAULTS


# Set up SOAP # Set up SOAP
self._soap = SOAPpy.WSDL.Proxy(settings.JIRA_URL + 'rpc/soap/jirasoapservice-v2?wsdl') self._soap = suds.client.Client(settings.JIRA_URL + 'rpc/soap/jirasoapservice-v2?wsdl')


# Authenticate # Authenticate
self._auth = self._soap.login(JIRA_USER, JIRA_PASSWORD) self._auth = self._soap.service.login(settings.JIRA_USER, settings.JIRA_PASSWORD)


except AttributeError: except AttributeError:
raise MiddlewareNotUsed raise MiddlewareNotUsed
Expand All @@ -41,8 +42,10 @@ def process_exception(self, request, exc):


# Otherwise, create it # Otherwise, create it
issue = settings.JIRA_ISSUE_DEFAULTS.copy() issue = settings.JIRA_ISSUE_DEFAULTS.copy()
issue['summary'] = traceback.format_exception_only(type(exc))[0] print exc
issue['description'] = traceback.format_exc() issue['summary'] = traceback.format_exception_only(type(exc), exc)[0]
issue['description'] = '{noformat:title=Traceback}\n' + traceback.format_exc() + '\n{noformat}\n\n' + \
'{noformat:title=Request}\n' + repr(request) + '\n{noformat}'


self._soap.createIssue(self._auth, issue) print self._soap.service.createIssue(self._auth, issue)


0 comments on commit b89f095

Please sign in to comment.