Skip to content

Commit

Permalink
chore(log): added try/catch clause and console.debug on catch
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Jan 8, 2024
1 parent 3db9247 commit b0ee67f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,25 @@ function getFields () {
* @returns {headRef: string; headhSha: string; baseRef: string; baseSha: string; issueUrl: string; htmlUrl: string; prTitle: string; senderAvatarUrl: string; senderHtmlUrl: string;}
*/
function getGhaEventData (eventFilePath, isGha) {
if (!eventFilePath || !isGha) {
return
}
try {
if (!eventFilePath || !isGha) {
return
}

const data = JSON.parse(fs.readFileSync(eventFilePath))
return {
headRef: data.pull_request.head.ref,
headhSha: data.pull_request.head.sha,
baseRef: data.pull_request.base.ref,
baseSha: data.pull_request.base.sha,
issueUrl: data.pull_request.issue_url,
htmlUrl: data.pull_request.html_url,
prTitle: data.pull_request.title,
senderAvatarUrl: data.sender.avatar_url,
senderHtmlUrl: data.sender.html_url
const data = JSON.parse(fs.readFileSync(eventFilePath))
return {
headRef: data.pull_request.head.ref,
headhSha: data.pull_request.head.sha,
baseRef: data.pull_request.base.ref,
baseSha: data.pull_request.base.sha,
issueUrl: data.pull_request.issue_url,
htmlUrl: data.pull_request.html_url,
prTitle: data.pull_request.title,
senderAvatarUrl: data.sender.avatar_url,
senderHtmlUrl: data.sender.html_url
}
} catch (e) {
console.debug('[GHA Data Error]: ', e)
}
}

Expand Down

0 comments on commit b0ee67f

Please sign in to comment.