syncfiles/macos/error.h
Dietrich Epp 4d4ee214b3 Create classic Mac OS GUI program
The GUI program's project is not checked in. It was compiled and tested
with CodeWarrior Pro 4.

The GUI program allows users to create new synchronization projects,
select folders to synchronize, and save and open projects. The code is
probably broken and buggy, and probably dereferences NULL pointers here
and there, but the basic shell is there.
2022-04-10 04:09:17 -04:00

49 lines
1.2 KiB
C

// error.h - Error handling.
#ifndef MACOS_ERROR_H
#define MACOS_ERROR_H
// Error codes, corresponding to messages in a STR# resource.
typedef enum {
kErrUnknown = 1,
kErrInternal,
kErrOutOfMemory,
kErrCouldNotSaveProject,
} ErrorCode;
struct Error {
ErrorCode code;
short osErr;
};
// Show an error dialog with the given error message, then quit the program.
void ExitError(ErrorCode errCode);
// Show an error dialog with the given error message and an OS error code, then
// quit the program.
void ExitErrorOS(ErrorCode errCode, short osErr);
// Show an out of memory error and quit the program.
void ExitMemError(void);
// Show an assertion error and quit the program.
void ExitAssert(const unsigned char *file, int line,
const unsigned char *message);
#define EXIT_ASSERT(str) ExitAssert("\p" __FILE__, __LINE__, str)
#define ASSERT(p) \
do { \
if (!(p)) \
ExitAssert("\p" __FILE__, __LINE__, "\p" #p); \
} while (0)
struct ErrorParams {
ErrorCode err;
OSErr osErr;
const unsigned char *strParam;
};
void ShowError(const struct ErrorParams *p);
#endif