Skip to content

Commit 1b867a7

Browse files
committed
ENH: added error events
1 parent 29afab4 commit 1b867a7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Diff for: lib/caronte/passes/web-incoming.js

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ function stream(req, res, options) {
102102
common.setupOutgoing(options.ssl || {}, options, req)
103103
);
104104

105+
proxyReq.on('error', function(err){
106+
var ev = 'caronte:outgoing:web:';
107+
if (options.ee.listeners(ev + 'error').length == 0){
108+
throw err;
109+
}
110+
options.ee.emit(ev + 'error', err, req, res);
111+
});
112+
105113
req.pipe(proxyReq);
106114

107115
proxyReq.on('response', function(proxyRes) {

Diff for: lib/caronte/passes/ws-incoming.js

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ function stream(req, socket, options, head) {
7878
var proxyReq = (~['https:', 'wss:'].indexOf(options.target.protocol) ? https : http).request(
7979
common.setupOutgoing(options.ssl || {}, options, req)
8080
);
81+
proxyReq.on('error', function(err){
82+
var ev = 'caronte:outgoing:ws:';
83+
if (options.ee.listeners(ev + 'error').length == 0){
84+
throw err;
85+
}
86+
options.ee.emit(ev + 'error', err, req, res);
87+
});
8188

8289
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
8390
common.setupSocket(proxySocket);

0 commit comments

Comments
 (0)