[haiku-commits] Re: haiku: hrev46978 - src/add-ons/translators/gif

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 05 Mar 2014 23:35:28 +0100

On 03/05/2014 11:22 PM, John Scipione wrote:
Can you kindly show me where BBitmap throws if it fails to allocate? I
can't find it.

"new" *always* throws. That's what new(std::nothrow) prevents.
Only in the latter case you must check for NULL.

Since throwing exceptions is not common throughout the Be API (unfortunately), you need to make sure that even if bad_alloc is thrown, all objects are cleaned up as they would have when you return B_NO_MEMORY.

From APIs, it is expected to return an error code rather than throwing an exception. As a general rule, if you return a status_t, don't throw.

Within applications, you can use exceptions however you want to, though.

Bye,
   Axel.


Other related posts: