qbit/node-pushover — pull request #12 by sweetpi (2014-10-11 07:23:23+00:00)
Title: Fixed error handling when https-request fails early

Thanks for this cool node module. I had some problems when I tried to send push notifications while my network was down:

```
node ./test/test-onerror.js
token=xxx&user=xxx&message=omg%20node%20test&sound=magic&title=Well%20-%20this%20is%20fantastic&device=&url=&url_title=&priority=×tamp=

events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
```

So the error didn't get catched and brought node down :(. I fixed the error handling by moving the error listener from the response object to the request object.

from: http://nodejs.org/api/http.html#http_http_request_options_callback
"If any error is encountered during the request (be that with DNS resolution, TCP level errors, or actual HTTP parse errors) an 'error' event is emitted on the returned __request__ object."