File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -252,21 +252,28 @@ export function triggerResourceLoading(
252252
253253 if ( tDetails . errorTmplIndex === null ) {
254254 const templateLocation = ngDevMode ? getTemplateLocationDetails ( lView ) : '' ;
255- let errorMsg : string | false = false ;
255+ let errorMsg = '' ;
256256
257257 if ( ngDevMode ) {
258258 errorMsg =
259259 'Loading dependencies for `@defer` block failed, ' +
260260 `but no \`@error\` block was configured${ templateLocation } . ` +
261261 'Consider using the `@error` block to render an error state.' ;
262262
263- const depsFnStr = tDetails . dependencyResolverFn ?. toString ( ) ?? 'unknown' ;
264- const errorReason = failedReason ? failedReason . message : 'Unknown' ;
265- errorMsg +=
266- `\n\nAngular tried to invoke the following dependency function (compiler-generated):\n` +
267- `\`\`\`\n${ depsFnStr } \n\`\`\`\n` +
268- `but it resulted in the following error:\n\n` +
269- `${ errorReason } ` ;
263+ const depsFn = tDetails . dependencyResolverFn ;
264+ const errorReason = failedReason ?. message ;
265+
266+ if ( depsFn ) {
267+ errorMsg +=
268+ `\n\nAngular tried to invoke the following dependency function (compiler-generated):\n` +
269+ `\`\`\`\n${ depsFn . toString ( ) } \n\`\`\`` ;
270+ }
271+
272+ if ( errorReason ) {
273+ errorMsg += depsFn
274+ ? `\n\nbut it resulted in the following error:\n\n${ errorReason } `
275+ : `\n\nThe loading resulted in the following error:\n\n${ errorReason } ` ;
276+ }
270277 }
271278
272279 const error = new RuntimeError ( RuntimeErrorCode . DEFER_LOADING_FAILED , errorMsg ) ;
Original file line number Diff line number Diff line change @@ -1224,7 +1224,6 @@ describe('@defer', () => {
12241224 expect ( reportedErrors . length ) . toBe ( 1 ) ;
12251225 const errorMsg = reportedErrors [ 0 ] . message ;
12261226 expect ( errorMsg ) . toContain ( 'NG0750' ) ;
1227- expect ( errorMsg ) . toContain ( 'Angular tried to invoke the following dependency function' ) ;
12281227 expect ( errorMsg ) . toContain ( 'Failed to load module X' ) ;
12291228 } ) ;
12301229
You can’t perform that action at this time.
0 commit comments