@@ -57,25 +57,25 @@ function buildErrorMessage(e: TModuleError) {
5757 } ;
5858}
5959
60+ const wrappedResolveModule = ( manager , path ) => {
61+ try {
62+ return manager && manager . resolveTranspiledModule ( path , '/' ) ;
63+ } catch ( e ) {
64+ return null ;
65+ }
66+ } ;
67+
6068function buildDynamicError ( ref : ErrorRecord ) {
6169 const manager = getCurrentManager ( ) ;
6270
63- const relevantFrame = ref . enhancedFrames . find ( r => {
64- try {
65- return (
66- manager &&
67- ! ! manager . resolveTranspiledModule (
68- ( r . _originalFileName || r . fileName || '' )
69- . replace ( location . origin , '' )
70- . replace ( 'file://' , '' ) ,
71- '/'
72- )
73- ) ;
74- } catch ( e ) {
75- /* don't do anything */
76- return false ;
77- }
78- } ) ;
71+ const relevantFrame = ref . enhancedFrames . find ( r =>
72+ wrappedResolveModule (
73+ manager ,
74+ ( r . _originalFileName || r . fileName || '' )
75+ . replace ( location . origin , '' )
76+ . replace ( 'file://' , '' )
77+ )
78+ ) ;
7979
8080 if ( relevantFrame && manager ) {
8181 const fileName = relevantFrame . _originalFileName || relevantFrame . fileName ;
@@ -102,11 +102,19 @@ function buildDynamicError(ref: ErrorRecord) {
102102 }
103103 } else {
104104 const error : TModuleError = ref . error ;
105- const tModule = error . tModule ;
105+ const tModule =
106+ error . tModule ||
107+ wrappedResolveModule (
108+ manager ,
109+ ( error . fileName || '' )
110+ . replace ( location . origin , '' )
111+ . replace ( 'file://' , '' )
112+ ) ;
106113
107114 if ( tModule ) {
108115 const newError = {
109116 ...buildErrorMessage ( error ) ,
117+ path : error . fileName ,
110118 type : 'action' ,
111119 action : 'show-error' ,
112120 } ;
@@ -121,6 +129,7 @@ function buildDynamicError(ref: ErrorRecord) {
121129/* eslint-disable no-underscore-dangle */
122130export default function showError ( ref : ErrorRecord ) {
123131 const errorToSend = buildDynamicError ( ref ) ;
132+
124133 if ( errorToSend ) {
125134 dispatch (
126135 actions . error . show ( errorToSend . title , errorToSend . message , {
@@ -130,5 +139,13 @@ export default function showError(ref: ErrorRecord) {
130139 payload : errorToSend . payload ,
131140 } )
132141 ) ;
142+ } else {
143+ // Show based on error
144+ actions . error . show ( ref . error . name , ref . error . message , {
145+ line : ref . error . lineNumber ,
146+ column : ref . error . columnNumber ,
147+ path : ref . error . fileName ,
148+ payload : { } ,
149+ } ) ;
133150 }
134151}
0 commit comments