@@ -19,7 +19,7 @@ var HydrationError = lib.HydrationError;
1919var logError = require ( '../utils' ) . logError ;
2020
2121
22- module . exports = function ( hydraterFunction , childs ) {
22+ module . exports = function ( hydraterFunction , childs , opbeatConfig ) {
2323 /**
2424 * Handle a hydration task:
2525 * - Download the file
@@ -75,8 +75,8 @@ module.exports = function(hydraterFunction, childs) {
7575 } ;
7676 cleaner . called = false ;
7777
78- child . process . on ( 'error' , function ( exitCode ) {
79- cleaner ( new HydrationError ( "Wild error appeared while spawning child. Exit code :" + exitCode ) ) ;
78+ child . process . on ( 'error' , function ( error ) {
79+ cleaner ( new HydrationError ( "Wild error appeared while spawning child. error :" + error ) ) ;
8080 } ) ;
8181
8282 child . process . stderr . on ( 'readable' , function ( ) {
@@ -119,17 +119,23 @@ module.exports = function(hydraterFunction, childs) {
119119 document : task . document ,
120120 changes : lib . defaultChanges ( ) ,
121121 options : options ,
122+ opbeatConfig : opbeatConfig
122123 } ) ;
123124
124125 child . process . on ( 'message' , function ( res ) {
125126 var err = res . err ;
126127 // If the function replied with an "HydrationError", we'll wrap this in a nicely formatted document
127128 // and stop the error from bubbling up.
128- if ( err && err . _hydrationError ) {
129- res . changes = { } ;
130- res . changes . hydration_errored = true ;
131- res . changes . hydration_error = err . message ;
132- err = null ;
129+ if ( err ) {
130+ if ( err . _hydrationError ) {
131+ res . changes = { } ;
132+ res . changes . hydration_errored = true ;
133+ res . changes . hydration_error = err . message ;
134+ err = null ;
135+ }
136+ else {
137+ err = err . message ? err . message : err ;
138+ }
133139 }
134140 cleaner ( err , res . changes ) ;
135141 } ) ;
0 commit comments