The best way to return errors from library

This is a discussion on The best way to return errors from library within the C Programming forums, part of the General Programming Boards category; Good afternoon, I made a command line utility and another colleague needs a library with similar functions (without command line ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    - 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21