iangreenleaf / githubot

Github API access, tailored for Hubot
MIT License
106 stars 37 forks source link

How to use a custom error handler? #30

Closed arnlen closed 8 years ago

arnlen commented 8 years ago

I would like to catch merging branch errors. Here is my code:

github  = require("githubot")(robot, errorHandler: (callback) -> 
    console.log ("Print this: #{callback}"))
app     = 'user/repo'

github.branches(app).merge "master", into: "production", (mergeCommit) ->
  [...]

And the response in my console:

[Mon Jun 27 2016 16:44:09 GMT+0200 (CEST)] ERROR Nothing to merge

Do you have a code example of a custom error handler? If you provide it, I would be able to update your documentation with a working example.

iangreenleaf commented 8 years ago

The way it's set up right now, the error still gets logged if you specify a handler. But the handler should be getting called… if it's still not working, you could try it this way and see if that changes anything (but, either way should work so it would be a bug):

github  = require("githubot")(robot)
github.handleErrors (callback) -> 
    console.log ("Print this: #{callback}"))
app     = 'user/repo'

github.branches(app).merge "master", into: "production", (mergeCommit) ->
  # ...
arnlen commented 8 years ago

Great! It works! 👍 I create a PR to improve doc on this point.

Thx a lot mate.