@@ -39,6 +39,7 @@ export const processError = (response) => {
3939 return {
4040 errorMessage : parsedResponse . message ,
4141 errorDetails : parsedResponse . details ,
42+ additionalInfo : parsedResponse . additionalInfo
4243 } ;
4344 }
4445 return false ;
@@ -106,32 +107,25 @@ const simulateNetwork = (payload) => createSimulateBackendCall(
106107 GEPPETTO . Resources . RUNNING_SIMULATION ,
107108) ;
108109
109- class ErrorDialogManager {
110- errorTag = 'SimulationId ' ;
111- errorIds = [ ] ;
112- addId ( id ) { this . errorIds . push ( id ) ; }
113- getErrorId ( s ) {
114- let errorId = 0 ;
115- const i = s . indexOf ( this . errorTag ) ;
116- if ( i > - 1 )
117- errorId = parseFloat ( s . substring ( i + this . errorTag . length , s . length - 1 ) ) ;
118- return errorId ;
119- }
120- shouldLaunch ( s ) {
121- const errorId = this . getErrorId ( s ) ;
122- if ( this . errorIds . indexOf ( errorId ) == - 1 && errorId > 0 )
123- {
124- this . errorIds . push ( errorId ) ;
110+ class PythonMessageFilter {
111+ errorIds = new Set ( ) ;
112+ shouldLaunch ( e ) {
113+ const errorId = e . additionalInfo ?. sim_id ;
114+ if ( ! errorId )
125115 return true ;
116+ if ( errorId )
117+ {
118+ if ( this . errorIds . has ( errorId ) )
119+ return false ;
120+ else {
121+ this . errorIds . add ( errorId ) ;
122+ return true ;
123+ }
126124 }
127- if ( errorId == 0 )
128- return true ;
129- if ( this . errorIds . indexOf ( errorId ) >= 0 )
130- return false ;
131125 }
132126}
133127
134- const errorDialogManager = new ErrorDialogManager ( ) ;
128+ const errorMessageFilter = new PythonMessageFilter ( ) ;
135129
136130export default ( store ) => ( next ) => ( action ) => {
137131 const switchLayoutAction = ( edit = true , reset = true ) => {
@@ -156,7 +150,7 @@ export default (store) => (next) => (action) => {
156150
157151 const pythonErrorCallback = ( error ) => {
158152 console . debug ( Utils . getPlainStackTrace ( error . errorDetails ) ) ;
159- if ( errorDialogManager . shouldLaunch ( error . errorMessage ) )
153+ if ( errorMessageFilter . shouldLaunch ( error ) )
160154 return next ( openBackendErrorDialog ( error ) ) ;
161155 else
162156 return next ( action ) ;
0 commit comments