[GRASS-dev] error reporting

Michael Barton michael.barton at asu.edu
Thu Sep 6 02:01:46 EDT 2007




On 9/5/07 9:27 AM, "Glynn Clements" <glynn at gclements.plus.com> wrote:

> 
> Michael Barton wrote:
> 
>> Here's the generic error function I planning to add. It seems to work pretty
>> good. Let me know if you see any problems or can suggest further
>> enhancements. I'm going to put it into gm.tcl where it will be available to
>> all GUI modules except gis_set.tcl (which runs before everything else, but
>> is not sourced by the main GUI).
>> 
>> proc Gm::errmsg { error args } {
>>     # send error report and optional message (args) to tk_messageBox
>>     
>>     set message ""
>>     
>>     if { $args != ""} {
>>         set message [G_msg [join $args]]
>>         append message ": "
>>      }
>> 
>>     tk_messageBox -type ok -icon error -title [G_msg "Error"] \
>>         -message "$message[G_msg $error]"
>>     uplevel 1 return
>>      
>> };
> 
> I'm not sure that it's appropriate for the translation to be done
> here; the caller has a better understanding of where the message
> boundaries lie.

It seems cleaner to work with in the scripts if we only need to put in the
error variable and a text string. This way ensures that the message gets
translated.

Is there someone out there with a non-english system that could test whether
this is a problem?

> 
> If it's done here, each arg should probably be translated
> individually; the caller can always join any arguments which should be
> translated as a whole. Even then, there's no option to have a portion
> which doesn't get translated.

Like this???

proc Gm::errmsg { error args } {
    # send error report and optional message (args) to tk_messageBox
    set message ""
    for arg in $args {

        if { $arg != "" } {
            append message "$arg "
        }
    }

    append message ": "

    tk_messageBox -type ok -icon error -title [G_msg "Error"] \
         -message "$message[G_msg $error]"
    uplevel 1 return
      
};

Only formatting drawback is that the end result will have "string string : "
(space before colon). Not a huge problem I guess.


You are right. A downside of enforcing translation within the function,
rather than relying on it to be done in the original script, is that the
whole thing gets translated. I'm not sure if this is really a problem with
short, optional error messages in reality.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton





More information about the grass-dev mailing list