File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ function createRightProxy(type) {
68
68
if ( typeof options [ e ] === 'string' )
69
69
options [ e ] = parse_url ( options [ e ] ) ;
70
70
} ) ;
71
-
71
+
72
72
if ( typeof this . emit === 'undefined' && ! cbl ) { throw new Error ( "You need to pass a callback to handle errors" ) }
73
73
74
74
for ( var i = 0 ; i < passes . length ; i ++ ) {
@@ -104,13 +104,22 @@ function ProxyServer(options) {
104
104
return ws [ pass ] ;
105
105
} ) ;
106
106
107
- this . on ( 'error' , function ( err ) {
108
- console . log ( err ) ;
109
- } ) ;
107
+ this . on ( 'error' , this . onError . bind ( this ) ) ;
108
+
110
109
}
111
110
112
111
require ( 'util' ) . inherits ( ProxyServer , EE3 ) ;
113
112
113
+ ProxyServer . prototype . onError = function ( err ) {
114
+ //
115
+ // Remark: Replicate node core behavior using EE3
116
+ // so we force people to handle their own errors
117
+ //
118
+ if ( this . listeners ( 'error' ) . length === 1 ) {
119
+ throw err ;
120
+ }
121
+ } ;
122
+
114
123
ProxyServer . prototype . listen = function ( port , hostname ) {
115
124
var self = this ,
116
125
closure = function ( req , res ) { self . web ( req , res ) ; } ;
You can’t perform that action at this time.
0 commit comments