Changed all error codes from enum values to macros. This allows for

compile time checks. Incidently those are not totally uncommon in
portable code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25385 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-05-08 20:54:14 +00:00
parent 173dd626bf
commit 965aa03f49
1 changed files with 134 additions and 147 deletions

View File

@ -11,112 +11,107 @@
/* Error baselines */
#define B_GENERAL_ERROR_BASE LONG_MIN
#define B_OS_ERROR_BASE B_GENERAL_ERROR_BASE + 0x1000
#define B_APP_ERROR_BASE B_GENERAL_ERROR_BASE + 0x2000
#define B_INTERFACE_ERROR_BASE B_GENERAL_ERROR_BASE + 0x3000
#define B_MEDIA_ERROR_BASE B_GENERAL_ERROR_BASE + 0x4000 /* - 0x41ff */
#define B_TRANSLATION_ERROR_BASE B_GENERAL_ERROR_BASE + 0x4800 /* - 0x48ff */
#define B_MIDI_ERROR_BASE B_GENERAL_ERROR_BASE + 0x5000
#define B_STORAGE_ERROR_BASE B_GENERAL_ERROR_BASE + 0x6000
#define B_POSIX_ERROR_BASE B_GENERAL_ERROR_BASE + 0x7000
#define B_MAIL_ERROR_BASE B_GENERAL_ERROR_BASE + 0x8000
#define B_PRINT_ERROR_BASE B_GENERAL_ERROR_BASE + 0x9000
#define B_DEVICE_ERROR_BASE B_GENERAL_ERROR_BASE + 0xa000
#define B_OS_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x1000)
#define B_APP_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x2000)
#define B_INTERFACE_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x3000)
#define B_MEDIA_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x4000)
/* - 0x41ff */
#define B_TRANSLATION_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x4800)
/* - 0x48ff */
#define B_MIDI_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x5000)
#define B_STORAGE_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x6000)
#define B_POSIX_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x7000)
#define B_MAIL_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x8000)
#define B_PRINT_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x9000)
#define B_DEVICE_ERROR_BASE (B_GENERAL_ERROR_BASE + 0xa000)
/* Developer-defined errors start at (B_ERRORS_END+1) */
#define B_ERRORS_END (B_GENERAL_ERROR_BASE + 0xffff)
#define B_ERRORS_END (B_GENERAL_ERROR_BASE + 0xffff)
/* General Errors */
enum {
B_NO_MEMORY = B_GENERAL_ERROR_BASE,
B_IO_ERROR,
B_PERMISSION_DENIED,
B_BAD_INDEX,
B_BAD_TYPE,
B_BAD_VALUE,
B_MISMATCHED_VALUES,
B_NAME_NOT_FOUND,
B_NAME_IN_USE,
B_TIMED_OUT,
B_INTERRUPTED,
B_WOULD_BLOCK,
B_CANCELED,
B_NO_INIT,
B_BUSY,
B_NOT_ALLOWED,
B_BAD_DATA,
B_DONT_DO_THAT,
#define B_NO_MEMORY (B_GENERAL_ERROR_BASE + 0)
#define B_IO_ERROR (B_GENERAL_ERROR_BASE + 1)
#define B_PERMISSION_DENIED (B_GENERAL_ERROR_BASE + 2)
#define B_BAD_INDEX (B_GENERAL_ERROR_BASE + 3)
#define B_BAD_TYPE (B_GENERAL_ERROR_BASE + 4)
#define B_BAD_VALUE (B_GENERAL_ERROR_BASE + 5)
#define B_MISMATCHED_VALUES (B_GENERAL_ERROR_BASE + 6)
#define B_NAME_NOT_FOUND (B_GENERAL_ERROR_BASE + 7)
#define B_NAME_IN_USE (B_GENERAL_ERROR_BASE + 8)
#define B_TIMED_OUT (B_GENERAL_ERROR_BASE + 9)
#define B_INTERRUPTED (B_GENERAL_ERROR_BASE + 10)
#define B_WOULD_BLOCK (B_GENERAL_ERROR_BASE + 11)
#define B_CANCELED (B_GENERAL_ERROR_BASE + 12)
#define B_NO_INIT (B_GENERAL_ERROR_BASE + 13)
#define B_BUSY (B_GENERAL_ERROR_BASE + 14)
#define B_NOT_ALLOWED (B_GENERAL_ERROR_BASE + 15)
#define B_BAD_DATA (B_GENERAL_ERROR_BASE + 16)
#define B_DONT_DO_THAT (B_GENERAL_ERROR_BASE + 17)
B_ERROR = -1,
B_OK = 0,
B_NO_ERROR = 0
};
#define B_ERROR (-1)
#define B_OK ((int)0)
#define B_NO_ERROR ((int)0)
/* Kernel Kit Errors */
enum {
B_BAD_SEM_ID = B_OS_ERROR_BASE,
B_NO_MORE_SEMS,
#define B_BAD_SEM_ID (B_OS_ERROR_BASE + 0)
#define B_NO_MORE_SEMS (B_OS_ERROR_BASE + 1)
B_BAD_THREAD_ID = B_OS_ERROR_BASE + 0x100,
B_NO_MORE_THREADS,
B_BAD_THREAD_STATE,
B_BAD_TEAM_ID,
B_NO_MORE_TEAMS,
#define B_BAD_THREAD_ID (B_OS_ERROR_BASE + 0x100)
#define B_NO_MORE_THREADS (B_OS_ERROR_BASE + 0x101)
#define B_BAD_THREAD_STATE (B_OS_ERROR_BASE + 0x102)
#define B_BAD_TEAM_ID (B_OS_ERROR_BASE + 0x103)
#define B_NO_MORE_TEAMS (B_OS_ERROR_BASE + 0x104)
B_BAD_PORT_ID = B_OS_ERROR_BASE + 0x200,
B_NO_MORE_PORTS,
#define B_BAD_PORT_ID (B_OS_ERROR_BASE + 0x200)
#define B_NO_MORE_PORTS (B_OS_ERROR_BASE + 0x201)
B_BAD_IMAGE_ID = B_OS_ERROR_BASE + 0x300,
B_BAD_ADDRESS,
B_NOT_AN_EXECUTABLE,
B_MISSING_LIBRARY,
B_MISSING_SYMBOL,
#define B_BAD_IMAGE_ID (B_OS_ERROR_BASE + 0x300)
#define B_BAD_ADDRESS (B_OS_ERROR_BASE + 0x301)
#define B_NOT_AN_EXECUTABLE (B_OS_ERROR_BASE + 0x302)
#define B_MISSING_LIBRARY (B_OS_ERROR_BASE + 0x303)
#define B_MISSING_SYMBOL (B_OS_ERROR_BASE + 0x304)
B_DEBUGGER_ALREADY_INSTALLED = B_OS_ERROR_BASE + 0x400
};
#define B_DEBUGGER_ALREADY_INSTALLED (B_OS_ERROR_BASE + 0x400)
/* Application Kit Errors */
enum {
B_BAD_REPLY = B_APP_ERROR_BASE,
B_DUPLICATE_REPLY,
B_MESSAGE_TO_SELF,
B_BAD_HANDLER,
B_ALREADY_RUNNING,
B_LAUNCH_FAILED,
B_AMBIGUOUS_APP_LAUNCH,
B_UNKNOWN_MIME_TYPE,
B_BAD_SCRIPT_SYNTAX,
B_LAUNCH_FAILED_NO_RESOLVE_LINK,
B_LAUNCH_FAILED_EXECUTABLE,
B_LAUNCH_FAILED_APP_NOT_FOUND,
B_LAUNCH_FAILED_APP_IN_TRASH,
B_LAUNCH_FAILED_NO_PREFERRED_APP,
B_LAUNCH_FAILED_FILES_APP_NOT_FOUND,
B_BAD_MIME_SNIFFER_RULE,
B_NOT_A_MESSAGE,
B_SHUTDOWN_CANCELLED,
B_SHUTTING_DOWN
};
#define B_BAD_REPLY (B_APP_ERROR_BASE + 0)
#define B_DUPLICATE_REPLY (B_APP_ERROR_BASE + 1)
#define B_MESSAGE_TO_SELF (B_APP_ERROR_BASE + 2)
#define B_BAD_HANDLER (B_APP_ERROR_BASE + 3)
#define B_ALREADY_RUNNING (B_APP_ERROR_BASE + 4)
#define B_LAUNCH_FAILED (B_APP_ERROR_BASE + 5)
#define B_AMBIGUOUS_APP_LAUNCH (B_APP_ERROR_BASE + 6)
#define B_UNKNOWN_MIME_TYPE (B_APP_ERROR_BASE + 7)
#define B_BAD_SCRIPT_SYNTAX (B_APP_ERROR_BASE + 8)
#define B_LAUNCH_FAILED_NO_RESOLVE_LINK (B_APP_ERROR_BASE + 9)
#define B_LAUNCH_FAILED_EXECUTABLE (B_APP_ERROR_BASE + 10)
#define B_LAUNCH_FAILED_APP_NOT_FOUND (B_APP_ERROR_BASE + 11)
#define B_LAUNCH_FAILED_APP_IN_TRASH (B_APP_ERROR_BASE + 12)
#define B_LAUNCH_FAILED_NO_PREFERRED_APP (B_APP_ERROR_BASE + 13)
#define B_LAUNCH_FAILED_FILES_APP_NOT_FOUND (B_APP_ERROR_BASE + 14)
#define B_BAD_MIME_SNIFFER_RULE (B_APP_ERROR_BASE + 15)
#define B_NOT_A_MESSAGE (B_APP_ERROR_BASE + 16)
#define B_SHUTDOWN_CANCELLED (B_APP_ERROR_BASE + 17)
#define B_SHUTTING_DOWN (B_APP_ERROR_BASE + 18)
/* Storage Kit/File System Errors */
enum {
B_FILE_ERROR = B_STORAGE_ERROR_BASE,
B_FILE_NOT_FOUND, /* deprecated: use B_ENTRY_NOT_FOUND instead */
B_FILE_EXISTS,
B_ENTRY_NOT_FOUND,
B_NAME_TOO_LONG,
B_NOT_A_DIRECTORY,
B_DIRECTORY_NOT_EMPTY,
B_DEVICE_FULL,
B_READ_ONLY_DEVICE,
B_IS_A_DIRECTORY,
B_NO_MORE_FDS,
B_CROSS_DEVICE_LINK,
B_LINK_LIMIT,
B_BUSTED_PIPE,
B_UNSUPPORTED,
B_PARTITION_TOO_SMALL
};
#define B_FILE_ERROR (B_STORAGE_ERROR_BASE + 0)
#define B_FILE_NOT_FOUND (B_STORAGE_ERROR_BASE + 1)
/* deprecated: use B_ENTRY_NOT_FOUND instead */
#define B_FILE_EXISTS (B_STORAGE_ERROR_BASE + 2)
#define B_ENTRY_NOT_FOUND (B_STORAGE_ERROR_BASE + 3)
#define B_NAME_TOO_LONG (B_STORAGE_ERROR_BASE + 4)
#define B_NOT_A_DIRECTORY (B_STORAGE_ERROR_BASE + 5)
#define B_DIRECTORY_NOT_EMPTY (B_STORAGE_ERROR_BASE + 6)
#define B_DEVICE_FULL (B_STORAGE_ERROR_BASE + 7)
#define B_READ_ONLY_DEVICE (B_STORAGE_ERROR_BASE + 8)
#define B_IS_A_DIRECTORY (B_STORAGE_ERROR_BASE + 9)
#define B_NO_MORE_FDS (B_STORAGE_ERROR_BASE + 10)
#define B_CROSS_DEVICE_LINK (B_STORAGE_ERROR_BASE + 11)
#define B_LINK_LIMIT (B_STORAGE_ERROR_BASE + 12)
#define B_BUSTED_PIPE (B_STORAGE_ERROR_BASE + 13)
#define B_UNSUPPORTED (B_STORAGE_ERROR_BASE + 14)
#define B_PARTITION_TOO_SMALL (B_STORAGE_ERROR_BASE + 15)
/* POSIX Errors */
#define E2BIG (B_POSIX_ERROR_BASE + 1)
@ -215,68 +210,60 @@ enum {
#define B_NOT_SUPPORTED EOPNOTSUPP
/* Media Kit Errors */
enum {
B_STREAM_NOT_FOUND = B_MEDIA_ERROR_BASE,
B_SERVER_NOT_FOUND,
B_RESOURCE_NOT_FOUND,
B_RESOURCE_UNAVAILABLE,
B_BAD_SUBSCRIBER,
B_SUBSCRIBER_NOT_ENTERED,
B_BUFFER_NOT_AVAILABLE,
B_LAST_BUFFER_ERROR
};
#define B_STREAM_NOT_FOUND (B_MEDIA_ERROR_BASE + 0)
#define B_SERVER_NOT_FOUND (B_MEDIA_ERROR_BASE + 1)
#define B_RESOURCE_NOT_FOUND (B_MEDIA_ERROR_BASE + 2)
#define B_RESOURCE_UNAVAILABLE (B_MEDIA_ERROR_BASE + 3)
#define B_BAD_SUBSCRIBER (B_MEDIA_ERROR_BASE + 4)
#define B_SUBSCRIBER_NOT_ENTERED (B_MEDIA_ERROR_BASE + 5)
#define B_BUFFER_NOT_AVAILABLE (B_MEDIA_ERROR_BASE + 6)
#define B_LAST_BUFFER_ERROR (B_MEDIA_ERROR_BASE + 7)
/* Mail Kit Errors */
enum {
B_MAIL_NO_DAEMON = B_MAIL_ERROR_BASE,
B_MAIL_UNKNOWN_USER,
B_MAIL_WRONG_PASSWORD,
B_MAIL_UNKNOWN_HOST,
B_MAIL_ACCESS_ERROR,
B_MAIL_UNKNOWN_FIELD,
B_MAIL_NO_RECIPIENT,
B_MAIL_INVALID_MAIL
};
#define B_MAIL_NO_DAEMON (B_MAIL_ERROR_BASE + 0)
#define B_MAIL_UNKNOWN_USER (B_MAIL_ERROR_BASE + 1)
#define B_MAIL_WRONG_PASSWORD (B_MAIL_ERROR_BASE + 2)
#define B_MAIL_UNKNOWN_HOST (B_MAIL_ERROR_BASE + 3)
#define B_MAIL_ACCESS_ERROR (B_MAIL_ERROR_BASE + 4)
#define B_MAIL_UNKNOWN_FIELD (B_MAIL_ERROR_BASE + 5)
#define B_MAIL_NO_RECIPIENT (B_MAIL_ERROR_BASE + 6)
#define B_MAIL_INVALID_MAIL (B_MAIL_ERROR_BASE + 7)
/* Printing Errors */
enum {
B_NO_PRINT_SERVER = B_PRINT_ERROR_BASE
};
#define B_NO_PRINT_SERVER (B_PRINT_ERROR_BASE + 0)
/* Device Kit Errors */
enum {
B_DEV_INVALID_IOCTL = B_DEVICE_ERROR_BASE,
B_DEV_NO_MEMORY,
B_DEV_BAD_DRIVE_NUM,
B_DEV_NO_MEDIA,
B_DEV_UNREADABLE,
B_DEV_FORMAT_ERROR,
B_DEV_TIMEOUT,
B_DEV_RECALIBRATE_ERROR,
B_DEV_SEEK_ERROR,
B_DEV_ID_ERROR,
B_DEV_READ_ERROR,
B_DEV_WRITE_ERROR,
B_DEV_NOT_READY,
B_DEV_MEDIA_CHANGED,
B_DEV_MEDIA_CHANGE_REQUESTED,
B_DEV_RESOURCE_CONFLICT,
B_DEV_CONFIGURATION_ERROR,
B_DEV_DISABLED_BY_USER,
B_DEV_DOOR_OPEN,
#define B_DEV_INVALID_IOCTL (B_DEVICE_ERROR_BASE + 0)
#define B_DEV_NO_MEMORY (B_DEVICE_ERROR_BASE + 1)
#define B_DEV_BAD_DRIVE_NUM (B_DEVICE_ERROR_BASE + 2)
#define B_DEV_NO_MEDIA (B_DEVICE_ERROR_BASE + 3)
#define B_DEV_UNREADABLE (B_DEVICE_ERROR_BASE + 4)
#define B_DEV_FORMAT_ERROR (B_DEVICE_ERROR_BASE + 5)
#define B_DEV_TIMEOUT (B_DEVICE_ERROR_BASE + 6)
#define B_DEV_RECALIBRATE_ERROR (B_DEVICE_ERROR_BASE + 7)
#define B_DEV_SEEK_ERROR (B_DEVICE_ERROR_BASE + 8)
#define B_DEV_ID_ERROR (B_DEVICE_ERROR_BASE + 9)
#define B_DEV_READ_ERROR (B_DEVICE_ERROR_BASE + 10)
#define B_DEV_WRITE_ERROR (B_DEVICE_ERROR_BASE + 11)
#define B_DEV_NOT_READY (B_DEVICE_ERROR_BASE + 12)
#define B_DEV_MEDIA_CHANGED (B_DEVICE_ERROR_BASE + 13)
#define B_DEV_MEDIA_CHANGE_REQUESTED (B_DEVICE_ERROR_BASE + 14)
#define B_DEV_RESOURCE_CONFLICT (B_DEVICE_ERROR_BASE + 15)
#define B_DEV_CONFIGURATION_ERROR (B_DEVICE_ERROR_BASE + 16)
#define B_DEV_DISABLED_BY_USER (B_DEVICE_ERROR_BASE + 17)
#define B_DEV_DOOR_OPEN (B_DEVICE_ERROR_BASE + 18)
B_DEV_INVALID_PIPE,
B_DEV_CRC_ERROR,
B_DEV_STALLED,
B_DEV_BAD_PID,
B_DEV_UNEXPECTED_PID,
B_DEV_DATA_OVERRUN,
B_DEV_DATA_UNDERRUN,
B_DEV_FIFO_OVERRUN,
B_DEV_FIFO_UNDERRUN,
B_DEV_PENDING,
B_DEV_MULTIPLE_ERRORS,
B_DEV_TOO_LATE
};
#define B_DEV_INVALID_PIPE (B_DEVICE_ERROR_BASE + 19)
#define B_DEV_CRC_ERROR (B_DEVICE_ERROR_BASE + 20)
#define B_DEV_STALLED (B_DEVICE_ERROR_BASE + 21)
#define B_DEV_BAD_PID (B_DEVICE_ERROR_BASE + 22)
#define B_DEV_UNEXPECTED_PID (B_DEVICE_ERROR_BASE + 23)
#define B_DEV_DATA_OVERRUN (B_DEVICE_ERROR_BASE + 24)
#define B_DEV_DATA_UNDERRUN (B_DEVICE_ERROR_BASE + 25)
#define B_DEV_FIFO_OVERRUN (B_DEVICE_ERROR_BASE + 26)
#define B_DEV_FIFO_UNDERRUN (B_DEVICE_ERROR_BASE + 27)
#define B_DEV_PENDING (B_DEVICE_ERROR_BASE + 28)
#define B_DEV_MULTIPLE_ERRORS (B_DEVICE_ERROR_BASE + 29)
#define B_DEV_TOO_LATE (B_DEVICE_ERROR_BASE + 30)
#endif /* _ERRORS_H */