Problem 1500

Summary: Graceful error handling in Qt interface
Product: Geant4 Reporter: Mojca Miklavec <mojca.miklavec.lists>
Component: visualizationAssignee: garnier
Status: RESOLVED FIXED    
Severity: normal CC: garnier, John.Allison, perl
Priority: P5    
Version: 9.6   
Hardware: All   
OS: All   

Description Mojca Miklavec 2013-07-25 20:02:18 CEST
When any simple error occurs, a Geant4 Qt application crashes in a hard way. In the most trivial case, forgetting to set the data environmental variables, the whole application first displays the following error (which is fine):

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : em0006
      issued by : G4SeltzerBergerModel::ReadData()
Environment variable G4LEDATA not defined
*** Fatal Exception *** core dump ***
-------- EEEE -------- G4Exception-END --------- EEEE -------

after clicking "OK" it shows another

*** G4Exception: Aborting execution ***

and after clicking "OK" again, it crashes, leaving the system message

exampleXX quit unexpectedly.
Click Reopen to open the application again. Click Report to see more detailed information and send a report to Apple.

Ignore | Report ... (a crash to Apple) | Reopen

Would it be possible to quit the application in a slightly less intrusive way, possibly saying more similar to "G4Exception: Application will quit now." and then exit normally without a crash / core dump?
Comment 1 garnier 2013-07-31 11:51:38 CEST
Yes, we know that and we are working on this. The best solution we could do is in this case of missing data set files, open a file selector and ask for them. We will try to improve this.

Thanks for your feedback, 

Laurent Garnier
Comment 2 Mojca Miklavec 2013-07-31 13:07:54 CEST
More than trying to find the data files, I meant handling errors in general. It would be very nice to exit the program gracefully rather than core-dumping it, even if some other error occurs.

About the data files, but that deserves a separate ticket, I believe: my favourite way would be the ability to hardcode the paths to the executable. Now that CMake-based Geant4 doesn't require setting any variable at all (everything "just works" - when compiling examples I just run "cmake /path/to/example"), it would be soooooo useful to be able to hardcode the paths at configuration/compilation time.

Options:
a) a CMake variable could set relative or absolute path to data sets and either add
    -DG4LEDATA="/path/to/datadir/G4EMLOW6.33"
to compiler flags or write a configuration file with
    #define G4LEDATA "/path/to/datadir/G4EMLOW6.33"
The loading code would then test for #ifdef G4LEDATA. The CMake files already know where the data files are, so this could be a trivial extension.

b) A configuration file would be written out (example: texmf.cnf in TeX) with data paths and possibly other variables in it; the data loading code would read that file, determine the path to data files if set and proceed as always if not.

I was already thinking of patching Geant4 sources in MacPorts where the path to data files is fixed anyway.

Anyway, sorry for being off-topic. When I file a new ticket I will copy the 
contents there ;)

This ticket was really about handling any error in Qt.
Comment 3 garnier 2013-11-25 11:12:50 CET
Marked as enhancement