Managing errors in a different language
Posted by nicolascastagne (nicolascastagne), 6 April 2005Hi all,
We are using Tcl for supporting a user-dedicated langage within a big GUI-based application developped in C++.
The user will use this language to manage some sort of "macros".
Nothing particular so far : tcl is adequate to this usage.
However, we encounter huge difficulties to manage the errors.
Indeed, we need to translate the errors in the appropriate language : italian, french, etc.
This is not a problem for the proc we provide ourselves. But how could we handle the errors generated within Tcl ?
For example, in case of a syntax error, we cannot display the basic Tcl output errorInfo to our user.
A solution would be to get a "error code" from Tcl, that we could "expand" in the appropriate string form. But, so far, we do not succeed in recovering any error code in the C++ code - only the wall char* errorInfo .
Is that possible ? Where can we find a description of all the error codes Tcl may generate ?
More generally, since Tcl is widely used for managing languages within apps... How is this problem handled usually ?
Thx in advance !
Posted by admin (Graham Ellis), 10 April 2005Hi, Nicolas ... I'm not ignoring the question, but this isn't one that I've come across personally and I was hoping that someone else had ...
Posted by Custard (Custard), 10 April 2005Hi,
I just wrote a lengthy post that completely missed the point after I re read your post..
According to my book,
Will run 'your code' and if there is an error, the catch returns a 1, and msg is set to whatever the error was.
If 'your code' was successful, catch returns a 0, and msg contains the return value from 'your code'
Is this any use?
Posted by admin (Graham Ellis), 11 April 2005Ah ... I had forgotten / overlooked catch. It might well be the trigger that Nicolas is looking for.
If that other lengthy piece of text is of general interest / as a tip on Tcl, do feel free to start a new thread, "B"
Posted by Custard (Custard), 11 April 2005Hi,
(Graham, I will post here as it is sort of pertinent to the subject of this thread even though the OP may have solved this bit already.
I just like this way as it enables use of java-like message bundles.
And you're lucky it was still in my cut-buffer!)
This is one of the briefs in my current project (which is admittedly perl, but the prinicples are the same).
What I have is a config file with entries for country/language like
And a class (in perl) which is initialised with these codes, and looks for a message bundle in a config directory. In my case, the message bundle would be config/Messages_EN_EN.
The message bundle (suspiciously similar in format to the Java message bundles) is loaded into a hash.
Empty parens () are substituted with args in the message function.
Then you can call the message function like
Translate my description into TCL-speak, and write your 'init' and 'message' function, and you're close.
I hope this is what you mean, and is helpful.
For perl there are various ways of doing it, and I'm sure there are for TCL, and maybe there is something out there. I rolled my own because it suited me to.
Posted by admin (Graham Ellis), 12 April 2005That takes me back to my days of CAD software writing ... with support for English and Norwegian. All meesages numbered, and the appropriate message file loaded without anything so fancy as a config file (but it was a very long time ago). We also had a reverse translation setup, as keywords and single letter confirmations entered were best translated too.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho