Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Sanchez-Mariscal committed Jan 12, 2015
1 parent a4843c9 commit 34848fc
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions grails-app/controllers/hipchat/addon/WebhookController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,35 @@ class WebhookController {

if (matcher) {
matcher.each {
String issueKey = it[0]
response = jira.get(path: "/issue/${issueKey}")
String issueTypeIcon = response.json.fields.issuetype.iconUrl
String summary = response.json.fields.summary
def resolution = response.json.fields.resolution
def status = response.json.fields.status
def assignee = response.json.fields.assignee

String message = """
<img src="${issueTypeIcon}"/> <strong><a href="${tenant.jiraUrl}/browse/${issueKey}">${summary}</a></strong> ${resolution?"\u2713":''}
<ul>
<li><em>Status</em>: <img src="${status.iconUrl}"/> ${status.name}</li>
${resolution?'': assignee ? "<li><em>Assignee</em>: <img src=\"${assignee.avatarUrls['16x16']}\" /> ${assignee.displayName}" : ''}
</ul>
""".trim()

sendRoomNotification(hipchat, roomId, message)

render status: 200
try {
String issueKey = it[0]
response = jira.get(path: "/issue/${issueKey}")
String issueTypeIcon = response.json.fields.issuetype.iconUrl
String summary = response.json.fields.summary
def resolution = response.json.fields.resolution
def status = response.json.fields.status
def assignee = response.json.fields.assignee

String message = """
<img src="${issueTypeIcon}"/> <strong><a href="${tenant.jiraUrl}/browse/${issueKey}">${summary}</a></strong> ${resolution?"\u2713":''}
<ul>
<li><em>Status</em>: <img src="${status.iconUrl}"/> ${status.name}</li>
${resolution?'': assignee ? "<li><em>Assignee</em>: <img src=\"${assignee.avatarUrls['16x16']}\" /> ${assignee.displayName}" : ''}
</ul>
""".trim()

sendRoomNotification(hipchat, roomId, message)
} catch (exception) {
//Tasty!
}

}
}
}

render status: 200
} else {
render status: 404
}

}
Expand Down

0 comments on commit 34848fc

Please sign in to comment.