Thread: The best way to return errors from library

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    9

    The best way to return errors from library

    Good afternoon, I made a command line utility and another colleague needs a library with similar functions (without command line output, etc.., with only a few parameters, like *buffer, offset and r/w parameter).

    I'm thinking about the best way to return errors from the library (a few kind of errors can occur, it can be quite detailed providing some conditions are met).

    I'm thinking about returning a pointer to an array with strings containing error messages..

    Do you have better idea?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    - return an integer result success / fail, and provide a "getLastError" function to get the detail.

    - return an integer encoding all possible error values

    Better?
    Well that depends on what you want to achieve and your PoV.

    There are choices for sure, but which is best for you is really down to you to decide.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why can't my perceptron learn correctly?
    By yann in forum C Programming
    Replies: 25
    Last Post: 10-15-2010, 12:26 AM
  2. New string functions
    By Elysia in forum C Programming
    Replies: 11
    Last Post: 03-28-2009, 05:03 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. string class errors
    By CodeMonkey in forum C++ Programming
    Replies: 13
    Last Post: 07-20-2003, 11:20 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM