Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass error object to callback instead of string on timeout #9

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ntpClient.getNetworkTime("pool.ntp.org", 123, function(err, date) {
## Contributors
* Clément Bourgeois (https://github.com/moonpyk)
* Callan Bryant (https://github.com/naggie)
* Gordon Hall (https://github.com/bookchin)

## License
Copyright (c) 2014 Clément Bourgeois
Licensed under the MIT license.

3 changes: 2 additions & 1 deletion lib/ntp-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@

var timeout = setTimeout(function () {
client.close();
callback("Timeout waiting for NTP response.", null);
callback(new Error("Timeout waiting for NTP response."), null);
errorFired = true;
}, exports.ntpReplyTimeout);

// Some errors can happen before/after send() or cause send() to was impossible.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ntp-client",
"description": "Pure Javascript implementation of the NTP Client Protocol",
"version": "0.5.3",
"version": "0.5.5",
"homepage": "https://github.com/moonpyk/node-ntp-client",
"author": {
"name": "Clément Bourgeois",
Expand Down
2 changes: 1 addition & 1 deletion test/ntp-client_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
ntpClient.getNetworkTime("google.com", 123, function (err, date) {
test.ok(err !== null);
test.ok(date === null);
test.equal(err, "Timeout waiting for NTP response.");
test.equal(err.message, "Timeout waiting for NTP response.");
test.done();
});
};
Expand Down