Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 562132d

Browse files
Merge pull request #33 from plotly/error-handling
handle request errors for `getFigure`, `getImage` and `stream`
2 parents 2289034 + e228142 commit 562132d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ Plotly.prototype.stream = function(token, callback) {
135135
}
136136
});
137137

138+
stream.on('error', function (err) {
139+
callback(err);
140+
});
141+
138142
if (stream.setTimeout) stream.setTimeout(Math.pow(2, 32) * 1000);
139143

140144
return stream;
@@ -175,6 +179,10 @@ Plotly.prototype.getFigure = function (fileOwner, fileId, callback) {
175179
});
176180
});
177181

182+
req.on('error', function (err) {
183+
callback(err);
184+
});
185+
178186
req.end();
179187
};
180188

@@ -219,6 +227,11 @@ Plotly.prototype.getImage = function (figure, opts, callback) {
219227
}
220228

221229
var req = https.request(options, handleResponse);
230+
231+
req.on('error', function (err) {
232+
callback(err);
233+
});
234+
222235
req.write(payload);
223236
req.end();
224237
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "plotly",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Simple node.js wrapper for the plot.ly API",
55
"main": "index.js",
66
"devDependencies": {

0 commit comments

Comments
 (0)