syncfiles/macos/error.h
Dietrich Epp d5bfaa510a Clean up Mac OS GUI code
Include paths are updated to include the directory. It seems that
CodeWarrior will search for include files recursively, which means that
"error.h" may resolve to the wrong file (there are two). I am unsure of
the rules CodeWarrior uses to find header files.

Support for older versions of Universal Interfaces has been added.

The project code has been reworked after thoroughly reviewing Inside
Macintosh: Files. It is not complete, but it compiles, and the behavior
of the Save / Save As commands have been thought out more carefully.
2022-11-16 18:19:05 -05:00

47 lines
1.4 KiB
C

// Copyright 2022 Dietrich Epp.
// This file is part of SyncFiles. SyncFiles is licensed under the terms of the
// Mozilla Public License, version 2.0. See LICENSE.txt for details.
#ifndef MACOS_ERROR_H
#define MACOS_ERROR_H
// Error codes, corresponding to messages in a STR# resource. This should be
// kept in sync with STR# rSTRS_Errors in resources.r.
typedef enum {
kErrUnknown = 1,
kErrInternal,
kErrOutOfMemory,
kErrCouldNotSaveProject,
} ErrorCode;
// 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;
short osErr;
const unsigned char *strParam;
};
void ShowError(const struct ErrorParams *p);
#endif