Intercept error in node requests to avoid process failing on connection refused or other errors.

This commit is contained in:
kangax 2011-09-08 15:56:59 -04:00
parent fe08e6aa3b
commit 6415c573fe
4 changed files with 22 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.5.9" };
var fabric = fabric || { version: "0.5.10" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;

13
dist/all.js vendored
View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.5.9" };
var fabric = fabric || { version: "0.5.10" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;
@ -10562,7 +10562,7 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
replacement.onload = function() {
_this.setElement(replacement);
callback && callback();
replacement.onload = canvasEl = imgEl = null;
replacement.onload = canvasEl = imgEl = imageData = null;
};
replacement.width = imgEl.width;
replacement.height = imgEl.height;
@ -11127,6 +11127,15 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
client = HTTP.createClient(80, oURL.hostname),
request = client.request('GET', oURL.pathname, { 'host': oURL.hostname });
client.addListener('error', function(err) {
if (err.errno === process.ECONNREFUSED) {
fabric.log('ECONNREFUSED: connection refused to ' + client.host + ':' + client.port);
}
else {
fabric.log(err.message);
}
});
request.end();
request.on('response', function (response) {
var body = "";

View file

@ -16,6 +16,15 @@
client = HTTP.createClient(80, oURL.hostname),
request = client.request('GET', oURL.pathname, { 'host': oURL.hostname });
client.addListener('error', function(err) {
if (err.errno === process.ECONNREFUSED) {
fabric.log('ECONNREFUSED: connection refused to ' + client.host + ':' + client.port);
}
else {
fabric.log(err.message);
}
});
request.end();
request.on('response', function (response) {
var body = "";

View file

@ -1,7 +1,7 @@
{
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"version": "0.5.9",
"version": "0.5.10",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
"repository": "git://github.com/kangax/fabric.js",