Results 1 to 7 of 7

Thread: Suggested Error Handling

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Qt products
    Qt5
    Platforms
    MacOS X
    Thanks
    13
    Thanked 153 Times in 150 Posts

    Default Re: Suggested Error Handling

    Quote Originally Posted by 33333 View Post
    The thing I find frustrating about trying to be like Qt and avoiding exceptions is constructors - which don't have a return value.
    I don't do anything in the default constructor or destructor for this very reason. I use the constructor initialization lists to do basic variable initialization (NULL for pointer, 0 for int, etc) and then I add init() and cleanup() methods for each class that I implement so that I can determine whether or not initialization or cleanup has been successful.

    I personally don't use exception handling and prefer that methods return success/failure indicators... I use either true/false for simple success/failure and use enums if I need to return different success/error values.

    Hope that helps.

    Jeff

  2. #2
    Join Date
    Oct 2012
    Posts
    132
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    10
    Thanked 21 Times in 21 Posts

    Default Re: Suggested Error Handling

    @33333: I think this FAQ will answer some of your questions: http://www.parashift.com/c++-faq-lite/exceptions.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.