@@ -140,24 +140,31 @@ module.exports = CoreObject.extend({
140140 // Verify there's a second line with path information.
141141 // (First line is the error message itself.)
142142 if ( stack [ 1 ] ) {
143- // Extract path and line number information. An example line looks like:
143+ // Extract path and line number information. An example line looks like either :
144144 // at /Users/monegraph/Code/fastboot-test/dist/fastboot/vendor.js:65045:19
145- var match = stack [ 1 ] . match ( / \s * a t ( [ ^ : ] + ) : ( \d + ) : ( \d + ) $ / ) ;
145+ // or
146+ // at Module.callback (/Users/monegraph/Code/fastboot test/dist/fastboot/fastboot-test.js:23:31)
147+ var match = stack [ 1 ] . match ( / \s * (?: a t .* \( ( [ ^ : ] + ) : ( \d + ) : ( \d + ) | a t ( [ ^ : ] + ) : ( \d + ) : ( \d + ) $ ) / ) ;
146148 if ( match ) {
149+ var fileName = match [ 1 ] || match [ 4 ] ;
150+ var lineNumber = match [ 2 ] || match [ 5 ] ;
151+
147152 // Print file name and line number from the top of the stack. This is displayed
148153 // anyway, of course, but not everyone knows how to read a stack trace. This makes
149154 // it more obvious.
150- var badFilePath = path . relative ( process . cwd ( ) , match [ 1 ] ) ;
151- preamble . push ( "Based on the stack trace, it looks like the exception was generated in " + badFilePath + " on line " + match [ 2 ] + "." ) ;
152- }
153-
154- // If the exception is coming from `vendor.js`, that usually means it's from an addon and thus may be
155- // out of the user's control. Give the user some instructions so they can try to figure out which
156- // addon is causing the problem.
157- if ( match && match [ 1 ] . substr ( - 9 ) === 'vendor.js' ) {
158- preamble . push ( "Because it's coming from vendor.js, an addon is most likely responsible for this error. You should look at this " +
159- "file and line number to determine which addon is not yet FastBoot compatible." ) ;
160-
155+ var badFilePath = path . relative ( process . cwd ( ) , fileName ) ;
156+ preamble . push ( "Based on the stack trace, it looks like the exception was generated in " + badFilePath + " on line " + lineNumber + "." ) ;
157+
158+ // If the exception is coming from `vendor.js`, that usually means it's from an addon and thus may be
159+ // out of the user's control. Give the user some instructions so they can try to figure out which
160+ // addon is causing the problem.
161+ if ( fileName . substr ( - 9 ) === 'vendor.js' ) {
162+ preamble . push ( "Because it's coming from vendor.js, an addon is most likely responsible for this error. You should look at this " +
163+ "file and line number to determine which addon is not yet FastBoot compatible." ) ;
164+
165+ } else {
166+ preamble . push ( "The exception is probably coming from your app. Look at this file and line number to determine what is triggering the exception." ) ;
167+ }
161168 }
162169 }
163170
0 commit comments