[GRASS-dev] error reporting

Michael Barton michael.barton at asu.edu
Wed Sep 5 00:19:01 EDT 2007


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
     
};

Michael


On 9/3/07 7:11 AM, "Glynn Clements" <glynn at gclements.plus.com> wrote:

> 
> For a start, if you add:
> 
> proc errorBox {msg} {
>     tk_messageBox -type ok -icon error -title [G_msg "Error"] -message $msg
> }
> 
> you would be able to replace e.g.:
> 
> tk_messageBox -type ok -icon error -title [G_msg "Error"] \
> -message [G_msg "Error creating tempfile: $error"]
> 
> (of which I see at least 102 occurrences) with just:
> 
> errorBox [G_msg "Error creating tempfile: $error"]
> 
> [
> BTW, this usage of G_msg is probably incorrect, as the entire message,
> including $error, will be used as the key. It should probably be:
> 
> errorBox "[G_msg {Error creating tempfile}]: $error"
> 
> or even:
> 
> errorBox "[G_msg {Error creating tempfile}]: [G_msg $error]"
> 
> so that "Error creating tempfile" and the error message will be
> translated independently. This means that you only need A+B
> translations instead of A*B. The second G_msg is only necessary if
> Tcl/Tk error messages aren't already localised by Tcl/Tk.
> 
> Note that the situation is different with C, where "%s" is included
> literally in the message key. In Tcl, $error will be substituted
> before the message is translated.
> ]

__________________________________________
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