@@ -17,6 +17,14 @@ window.scout = client;
17
17
18
18
var wrapError = require ( './wrap-error' ) ;
19
19
20
+ /**
21
+ * Catch-all for any client errors so we just log them instead of
22
+ * stopping the app.
23
+ */
24
+ client . on ( 'error' , function ( err ) {
25
+ console . error ( err ) ;
26
+ } ) ;
27
+
20
28
var SampledSchema = Schema . extend ( {
21
29
fetch : function ( options ) {
22
30
options = _ . defaults ( ( options || { } ) , {
@@ -28,7 +36,7 @@ var SampledSchema = Schema.extend({
28
36
wrapError ( this , options ) ;
29
37
30
38
var model = this ;
31
- var detect = this . stream ( )
39
+ var parser = this . stream ( )
32
40
. on ( 'error' , function ( err ) {
33
41
options . error ( err , 'error' , err . message ) ;
34
42
} )
@@ -40,7 +48,9 @@ var SampledSchema = Schema.extend({
40
48
41
49
model . trigger ( 'request' , model , { } , options ) ;
42
50
process . nextTick ( function ( ) {
43
- client . sample ( model . ns , options ) . pipe ( detect ) ;
51
+ client . sample ( model . ns , options )
52
+ . on ( 'error' , parser . emit . bind ( parser , 'error' ) )
53
+ . pipe ( parser ) ;
44
54
} ) ;
45
55
}
46
56
} ) ;
0 commit comments