@@ -276,7 +276,7 @@ def MakePaneContent(self, pane):
276276 # Set initial values and enable/disable based on package
277277 if DEFAULT_DEVS_DIRNAME == 'PyDEVS' :
278278 self .cb2 .SetValue (NTL )
279- self .cb3 .Enable ( False )
279+ self .cb3 .SetValue ( VERBOSE )
280280 cb4 .Enable (False )
281281 cb5 .Enable (False )
282282 elif DEFAULT_DEVS_DIRNAME == 'BrokerDEVS' :
@@ -292,6 +292,11 @@ def MakePaneContent(self, pane):
292292 cb4 .SetValue (DYNAMIC_STRUCTURE )
293293 cb5 .SetValue (REAL_TIME and not NTL )
294294
295+ # Disable and uncheck verbose if plugin is not enabled
296+ if not PluginManager .is_enable ('verbose' ):
297+ self .cb3 .SetValue (False )
298+ self .cb3 .Enable (False )
299+
295300 pane .SetSizer (main_sizer )
296301
297302 # Bind events
@@ -606,8 +611,9 @@ def OnText(self, event):
606611 def OnViewLog (self , event ):
607612 """ When View button is clicked
608613 """
609- # The simulation verbose event occurs
610- PluginManager .trigger_event ('START_SIM_VERBOSE' , parent = self )
614+ # The simulation verbose event occurs only if verbose is enabled
615+ if self .verbose :
616+ PluginManager .trigger_event ('START_SIM_VERBOSE' , parent = self )
611617
612618 # The activity tracking event occurs
613619 PluginManager .trigger_event ('VIEW_ACTIVITY_REPORT' , parent = self , master = self .current_master )
@@ -947,39 +953,55 @@ def ErrorManager(self, msg):
947953
948954 ### try to find the file which have the error from traceback
949955 devs_error = False
956+ # the pubsub call may pass whatever it likes; the original code assumed a
957+ # (type, value, traceback) tuple and would crash if msg was anything else.
958+ # be defensive: if unpacking fails treat it as a non‑devs error and fall
959+ # through to the generic handler below.
950960 try :
951- typ , val , tb = msg
952- trace = traceback .format_exception (typ , val , tb )
953-
954- ### paths in traceback
955- paths = [a for a in trace if a .split (',' )[0 ].strip ().startswith ('File' )]
956-
957- ### find if DOMAIN_PATH is in the first file path of the trace
958- path = paths [- 1 ]
959- devs_error = DOMAIN_PATH in path or DEVSIMPY_PACKAGE_PATH not in path
960-
961+ if isinstance (msg , tuple ) and len (msg ) == 3 :
962+ typ , val , tb = msg
963+ trace = traceback .format_exception (typ , val , tb )
964+
965+ ### paths in traceback
966+ paths = [a for a in trace if a .split (',' )[0 ].strip ().startswith ('File' )]
967+ if paths :
968+ # find if DOMAIN_PATH is in the last file path of the trace
969+ p = paths [- 1 ]
970+ devs_error = DOMAIN_PATH in p or DEVSIMPY_PACKAGE_PATH not in p
971+ else :
972+ # msg didnt look like a tuple, maybe pubsub gave keyword args
973+ sys .stdout .write (_ ("ErrorManager received unexpected message type %r\n " ) % (msg ,))
961974 except Exception as info :
962- sys .stdout .write (_ ("Error in ErrorManager: %s" % info ))
963-
975+ sys .stdout .write (_ ("Error in ErrorManager: %s" % info ))
976+
964977 ### if error come from devs python file
965978 if devs_error :
966979
967980 try :
968981 ### simulate event button for the code editor
969982 event = wx .PyCommandEvent (wx .EVT_BUTTON .typeId , self ._btn1 .GetId ())
970- except :
983+ except Exception :
971984 pass
972985 else :
973986 ### Error dialog
974- if not Container .MsgBoxError (event , self . parent , msg ):
975- ### if user dont want correct the error, we destroy the simulation windows
987+ if not Container .MsgBoxError (event , getattr ( self , ' parent' , None ) , msg ):
988+ ### if user dont want correct the error, we destroy the simulation windows
976989 self .PrepareDestroyWin ()
977990 self .Destroy ()
978991 else :
979- ### if user want to correct error through an editor, we stop simulation process for trying again after the error is corrected.
992+ ### if user want to correct error through an editor, we stop simulation process for trying again after the error is corrected.
980993 self .OnStop (event )
981994 else :
982- raise MyBad (msg )
995+ # treat any other error the same way instead of raising; on real
996+ # non‑devs errors we simply show a message box and tear down the
997+ # simulation so the program can continue gracefully.
998+ try :
999+ Container .MsgBoxError (None , getattr (self , 'parent' , None ), msg )
1000+ except Exception as info2 :
1001+ sys .stdout .write (_ ("Error displaying error dialog: %s\n Original: %r" ) % (info2 , msg ))
1002+ # ensure simulation windows are cleaned up
1003+ self .PrepareDestroyWin ()
1004+ self .Destroy ()
9831005
9841006class SimulationDialogPanel (Base , wx .Panel ):
9851007 """ Simulation Dialog Panel
0 commit comments