Skip to content

Commit

Permalink
Notify user when there is error with github API request
Browse files Browse the repository at this point in the history
  • Loading branch information
saiqulhaq committed Jan 25, 2018
1 parent 604396c commit 833a1ba
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 21 deletions.
54 changes: 36 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/components/Hackmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ export default {
const indexResult = this.projects.findIndex(project => project.id === id)
this.projects.splice(indexResult, 1)
})
},
notifyError (msg) {
if (msg.hasOwnProperty('message')) {
alert(msg.message)
} else {
alert('Oh no, something went wrong')
}
}
},
components: {
Expand Down Expand Up @@ -197,7 +204,10 @@ export default {
this.username = response.data.login
this.userId = response.data.id
},
issueNumber: this.issueNumber
issueNumber: this.issueNumber,
onError: errMsg => {
this.notifyError(errMsg)
}
})
// we need to calculate map dimensions in order to place the avatars
// we handle three cases:
Expand Down
5 changes: 4 additions & 1 deletion src/github-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export default class GitHubIssueService {
this.issueNumber = issue.number
})
.then(() => this.pollIssueForComments())
.catch(err => this.reportError(err))
.catch(err => {
this.reportError(err)
config.onError(err)
})
}

postNewProject (project) {
Expand Down
2 changes: 1 addition & 1 deletion test/github-api-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('baseURL', () => {

let token = 'token'
let config = {
organization: 'saiqulhaq',
organization: 'bkkhack',
repository: 'hackmap',
}

Expand Down

0 comments on commit 833a1ba

Please sign in to comment.