Results 1 to 2 of 2

Thread: Error handling guidelines?

  1. #1
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Question Error handling guidelines?

    Are there any general guidelines about how to implement error handling in Qt code? What I mean are things like checking input parameters to functions and what to do in case of invalid parameters:
    1. fail silently and do nothing?
    2. return an error code as the result?
    3. return 'false' and log an error message somewhere for the caller to get it?
    4. emit a warning message and use a default value instead?
    5. emit a warning and abort (Q_ASSERT, qFail(), ...)?
    6. raise an exception?
    7. or...?

    Well I guess it depends also on the application what would be the correct action. Anyway, I haven't seen these issues discussed much in the Qt documentation, so I wanted to know if there are some common practices people usually follow?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Error handling guidelines?

    I haven't seen these issues discussed much in the Qt documentation,
    Thats because its not Qt issue.
    This is not even a language issue.

    There are no general guide lines for that.
    There are various philosophies for error handling, and you should pick the one that best suits your project.
    http://en.wikibooks.org/wiki/C_Progr...Error_handling
    http://en.wikipedia.org/wiki/Exception_handling
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Suggested Error Handling
    By Max Yaffe in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2014, 17:29
  2. QWebPage error handling
    By Guilo in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2010, 05:48
  3. QThread Error Handling
    By TheJim01 in forum Newbie
    Replies: 2
    Last Post: 8th April 2010, 14:54
  4. Help regarding guidelines
    By Nishant in forum Newbie
    Replies: 4
    Last Post: 20th October 2009, 19:49
  5. QNetworkReply error handling
    By timmu in forum Qt Programming
    Replies: 5
    Last Post: 25th August 2009, 09:07

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.