[GRASS-dev] [GRASS GIS] #2326: Command functions in grass.script.core miss a correct error reporting

GRASS GIS trac at osgeo.org
Tue Jun 24 17:41:03 PDT 2014


#2326: Command functions in grass.script.core miss a correct error reporting
--------------------------------+-------------------------------------------
 Reporter:  wenzeslaus          |       Owner:  grass-dev@…              
     Type:  enhancement         |      Status:  new                      
 Priority:  major               |   Milestone:  7.1.0                    
Component:  Python              |     Version:  svn-trunk                
 Keywords:  script, exceptions  |    Platform:  All                      
      Cpu:  Unspecified         |  
--------------------------------+-------------------------------------------

Comment(by wenzeslaus):

 When trying to implement new version of what we are talking about I run
 into the following problem. G7:g.message which is called by `core.fatal`
 exits with non-zero return code.

 {{{
 # test runs of g.message
 > g.message "no flag"; echo "$?"
 no flag
 0
 > g.message -v "flag -v"; echo "$?"
 0
 > g.message -i "flag -i"; echo "$?"
 flag -i
 0
 > g.message -w "flag -w"; echo "$?"
 WARNING: flag -w
 0
 > g.message -e "flag -e"; echo "$?"
 ERROR: flag -e
 1
 }}}

 This causes `run_command` which is used to call `g.message` to call
 `core.fatal` and infinite recursion goes on. `g.message` calls
 `G_fatal_error` which in causes the exit with return code 1.

 This can be fixed in `core.fatal` (`core.error`) for example by using
 `start_command` directly. However, the behavior of `g.message` is not
 expected. When it successfully prints the error, it should end
 successfully. Wouldn't be better to change `g.message` to return 0 with
 `-e` flag?

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2326#comment:10>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list