Please support our sponsors!
This service provided by BeBits: The Best Source of BeOS Software!
ApiGeneralDesignIssues

Exceptions

I would like to see API wide use of exceptions for errors (where ever possible). I understand that you can't use exceptions in system level code (e.g. kernel), but the 'new' operator already throws an exception if it encounters an error. This makes it difficult to write clean constructors since everything else returns error codes. I think that in general creating objects on the stack (when ever possible) and throwing exceptions makes for cleaner code (at least execution wise). That way if an error is encountered and an exception is thrown the stack is unwound for you automagically and you don't have to worry about empty pointers or orphaned objects. Error code returns from functions seems so 1995 to me. Death to status_t!

Either way, the bottom line is: YOU SHOULD BE CATCHING EXCEPTIONS! The 'new' operator throws them...period.

References:
Using C++ in the kernel
BeNewsletter, Volume III, Issue 51

(I thought there were some articles about exceptions and the 'new' operator, too. Can't find 'em.)
-- Paul J. Stadig

Some info can be found in Effective C++, Item 7.


IndexPage | TableOfContents

PAGE VISITS
1,678

LINKS HERE
IndexPage
ApiDesign

NEW PAGES
BuildingCairo
StoringDataInBetweenOSes
ScriptingBeosRuby
ScriptingBeosPython
HaikuOS
QemUwinbe
MinimalBeos
XpMBRoverwrite
SteveSakoman
MailingLists

RECENT CHANGES
BuildingCairo
BeCommunity
BuildingFirebird
PlayGround
CorumIII
BeAcademic
SupportForMachinesAndArchitectures
BeOsReleases
HowTo
HaikuOS
Edit Page | Front Page | BeBits
Site content is in the public domain. Unless otherwise noted, everything else is copyright © 1999-2002 Fifth Ace Productions, LLC. All Rights Reserved.
For more legal trivia, take a gander at our
Legal Stuff page and our Privacy Statement.
Fifth Ace Productions