C++/Tcl
A C++ library for interoperability between C++ and Tcl


[prev][top][next]

Errors

All Tcl errors, conversion errors and others that may take place when calling Tcl code from C++, are translated and reported as exceptions of the tcl_error type:

namespace Tcl
{
     class tcl_error : public std::runtime_error
     {
          // ...
     };
}

This means that the simplest framework for handling such errors may look like:

int main()
{
     try
     {
           interpreter i;
           // ...
     }
     catch (tcl_error const &e)
     {
          // some Tcl error
     }
     catch (exception const &e)
     {
          // some other error
     }
}

On the other hand, when calling C++ from Tcl, all C++ exceptions are translated and presented as regular Tcl errors, with error message taken from the C++ exception, if it was from the std::exception family. For all other C++ exceptions, the "Unknown error." message is returned.


[prev][top][next]


Copyright © 2004-2006, Maciej Sobczak