The Support Kit: Error Codes

Error codes are returned by various functions to indicate the success or to describe the failure of a requested operation. All Be error constants except for B_NO_ERROR are negative integers; any function that returns an error code can thus be generally tested for success or failure by the following:

   if ( funcCall() < B_NO_ERROR )
      /* failure */
   else
      /* success */

Furthermore, all constants (except B_NO_ERROR and B_ERROR) are less than or equal to the value of the B_ERRORS_END constant. If you want to define your own negative-valued error codes, you should begin with the value ( B_ERRORS_END + 1) and work your way toward 0.


General Error Codes

Declared in: <support/Errors.h>

Error Code Meaning
B_NO_MEMORY There's not enough memory for the operation.
B_IO_ERROR A general input/output error occurred.
B_PERMISSION_DENIED The operation isn't allowed.
B_FILE_ERROR A file error occurred.
B_FILE_NOT_FOUND The specified file doesn't exist.
B_BAD_INDEX The index is out of range.
B_BAD_VALUE An illegal value was passed to the function.
B_MISMATCHED_VALUES Conflicting values were passed to the function.
B_BAD_TYPE An illegal argument type was named or passed.
B_NAME_NOT_FOUND There's no match for the specified name.
B_NAME_IN_USE The requested (unique) name is already used.
B_TIMED_OUT Time expired before the operation was finished.
B_INTERRUPTED A signal interrupted the operation.
B_ERROR = -1 This is a convenient catchall for general errors.
B_NO_ERROR = 0 Everything's OK.
B_ERRORS_END Marks the end of all Be-defined error codes.


Application Kit Error Codes

Declared in: <support/Errors.h>

Error Code Meaning
B_DUPLICATE_REPLY A previous reply message has already been sent.
B_BAD_REPLY The reply message is inappropriate and can't be sent
B_BAD_HANDLER The designated message handler isn't valid.
B_MESSAGE_TO_SELF A thread is trying to send a message to itself.
B_ALREADY_RUNNING The application can't be launched again.
B_LAUNCH_FAILED The attempt to launch the application failed.

These constants are defined for the messaging classes of the Application Kit. The messaging system also makes use of some of the general errors and kernel errors described above.

See also: BMessage::Error() and BMessenger::Error()


Debugger Error Codes

Declared in: <support/Errors.h>

Error Code
B_DEBUGGER_ALREADY_INSTALLED

This constant signals that the debugger has already been installed for a particular team and can't be installed again.


Kernel Kit Error Codes

Declared in: <support/Errors.h>

Error Code Meaning
B_BAD_THREAD_ID Specified thread identifier (thread_id) is invalid.
B_BAD_THREAD_STATE The thread is in the wrong state for the operation.
B_NO_MORE_THREADS All thread identifiers are currently taken.
B_BAD_TEAM_ID Specified team identifier ( team_id) is invalid.
B_NO_MORE_TEAMS All team identifiers are currently taken.
B_BAD_PORT_ID Specified port identifier ( port_id) is invalid.
B_NO_MORE_PORTS All port identifiers have been taken.
B_BAD_SEM_ID Semaphore identifier (sem_id ) is invalid.
B_NO_MORE_SEMS All semaphores are currently taken.
B_BAD_IMAGE_ID Specified image identifier (image_id) is invalid.

These error codes are returned by functions in the Kernel Kit, and occasionally by functions defined in higher level kits.


Media Kit Error Codes

Declared in: <support/Errors.h>

Error Code Meaning
B_STREAM_NOT_FOUND The attempt to locate the stream failed.
B_SERVER_NOT_FOUND The attempt to locate the server failed.
B_RESOURCE_NOT_FOUND The attempt to locate the resource failed.
B_RESOURCE_UNAVAILABLE Permission to access the resource was denied.
B_BAD_SUBSCRIBER The BSubscriber is invalid.
B_SUBSCRIBER_NOT_ENTERED The BSubscriber hasn't entered the stream.
B_BUFFER_NOT_AVAILABLE The attempt to acquire the buffer failed.

These error codes are defined for the Media Kit. See the classes and functions in that kit for an explanation of how they're used.




The Be Book, HTML Edition, for Developer Release 8 of the Be Operating System.

Copyright © 1996 Be, Inc. All rights reserved.

Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.

Last modified September 6, 1996.