From: Issac Trotts Date: 2001-12-14T07:12:30+09:00 Subject: [ruby-talk:28464] Re: ANNOUNCE: Extending Ruby With C++ Mini > > > Sure. Maybe I should include something about this later in the > > HOW-TO. What sorts of exceptions could be thrown by the > > code I wrote? Maybe the 10-element int array wouldn't get allocated > > it seems like that will almost never happen. > > std::vector::push_back() can throw an std::bad_alloc. > This is probably > a rare condition, but if you can handle this exception then you can > handle the case where you aren't using built-in types. If I have a > user-defined type Foo, and I create a vector of Foo, and Foo's > constructor throws a FooException in certain cases, then I need to be > prepared to handle that exception (preferably genericly, so that if I > decide to use a vector instead, and Bar's constructor throws a > BarException, my code will continue to remain exception-safe). That's sensible. I should at least allude to it in the how-to, though I don't want to intimidate the reader with too much tangled code. > If you enable exceptions on cout, then there are many exceptions that > could be thrown; these all inherit from std::ios::failure. An example > of when such an exception might be thrown is if stdout is being > redirected to a file, and you run out of disk space. > > > Good points. Thanks for the input. > > Nice job on the mini-howto, btw. I wish I had time to write many > similar documents myself, but there is so much to do and so little > time... :) > > Paul Things like this happen when the next deadline is 20 months away :). Issac