> try
> {
[quoted text clipped - 6 lines]
>
> How do I get the type (int) and the value (1) of the exception thrown?
I don't think System::Exception contains enough type information about
unmanaged exceptions. You have to catch int as an unmanaged exception.
You should always catch unmanaged exceptions first, then managed ones,
like this:
try
{
throw int(10);
//throw std::exception("a"); // try this too
}
catch(std::exception& ex)
{
Console::WriteLine("std::exception: " + gcnew String(ex.what()));
}
catch(int value)
{
Console::WriteLine("int: " + value.ToString());
}
catch(Exception^ ex)
{
Console::WriteLine("Exception^: " + ex->Message);
}
It doesn't matter if you catch int or std::exception first, but
Exception^ goes last. Also, the most derived type in the hierarchy goes
first:
try
{
}
catch(std::runtime_error& )
{
}
catch(std::exception& )
{
}
Tom
Maxim - 17 Feb 2007 00:47 GMT
Thanks, Tom
>> try
>> {
[quoted text clipped - 45 lines]
>
> Tom