This doesn't seem to behave as I would expect (as it does in matlab, for example). I want to execute a command, but give some readable output instead of the often very messy auto-generated error (index out of range or something).

catch(char* str)
  cout << "There was a problem." << endl;

Is that now how you do this in c++?



Your syntax is correct, but you are probably not catching the correct thing. Usually the standard error is a descendant of runtime_error in <stdexcept>.

Take a read through
and check 17.6 and 17.7.

Hope this helps.

ah - i see, i wasn't throwing anything, so clearly it was not being caught! Thanks for the link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.