victorprad / InfiniTAM

A Framework for the Volumetric Integration of Depth Images
http://www.infinitam.org
Other
930 stars 351 forks source link

Make the OpenNIEngine constructor throw on fatal errors, and remove a redundant condition. #5

Closed sgolodetz closed 9 years ago

sgolodetz commented 9 years ago

Shutting down OpenNI means that OpenNIEngine construction has irretrievably failed. The standard way of handling failures in constructors is to throw (aborting construction of the object) rather than returning (which leaves the object in a partially-constructed and failed state). Partially-constructed objects can be dangerous if people use them as if they were fully-constructed ones. To avoid problems, it's much safer just to never partially construct objects in the first place.

See also: http://www.gotw.ca/publications/mill13.htm