2022-04-10 08:22:58 +00:00
|
|
|
// 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.
|
2022-04-10 08:09:17 +00:00
|
|
|
#ifndef MACOS_ERROR_H
|
|
|
|
#define MACOS_ERROR_H
|
|
|
|
|
2022-11-16 23:19:05 +00:00
|
|
|
// Error codes, corresponding to messages in a STR# resource. This should be
|
|
|
|
// kept in sync with STR# rSTRS_Errors in resources.r.
|
2023-05-06 23:41:40 +00:00
|
|
|
typedef enum ErrorCode {
|
|
|
|
// (no error)
|
|
|
|
kErrNone,
|
2022-11-18 01:38:03 +00:00
|
|
|
// Out of memory.
|
2022-04-10 08:09:17 +00:00
|
|
|
kErrOutOfMemory,
|
2022-11-18 01:38:03 +00:00
|
|
|
// Could not save project "^1".
|
2022-04-10 08:09:17 +00:00
|
|
|
kErrCouldNotSaveProject,
|
2023-05-06 23:41:40 +00:00
|
|
|
// Could not read project "^1".
|
|
|
|
kErrCouldNotReadProject,
|
|
|
|
// The project file is damaged.
|
|
|
|
kErrProjectDamaged,
|
2023-05-07 02:24:50 +00:00
|
|
|
// The project data is too large.
|
|
|
|
kErrProjectLarge,
|
2023-05-06 23:41:40 +00:00
|
|
|
// The project file is from an unknown version of SyncFiles.
|
|
|
|
kErrProjectUnknownVersion,
|
|
|
|
// Could not query volume parameters.
|
|
|
|
kErrVolumeQuery,
|
|
|
|
// Could not create alias.
|
|
|
|
kErrAlias,
|
|
|
|
// Could not get directory path.
|
2023-05-07 02:55:06 +00:00
|
|
|
kErrDirPath,
|
|
|
|
// Local project directory not found.
|
|
|
|
kErrLocalNotFound,
|
|
|
|
// Remote project directory not found.
|
|
|
|
kErrRemoteNotFound,
|
|
|
|
// The volume is not mounted.
|
|
|
|
kErrNotMounted
|
2022-04-10 08:09:17 +00:00
|
|
|
} ErrorCode;
|
|
|
|
|
2023-05-06 23:41:40 +00:00
|
|
|
// ExitAssert shows an assertion error and quits the program. Either the file or
|
|
|
|
// the assertion may be NULL.
|
2022-04-10 08:09:17 +00:00
|
|
|
void ExitAssert(const unsigned char *file, int line,
|
2023-05-06 23:41:40 +00:00
|
|
|
const unsigned char *assertion);
|
|
|
|
|
|
|
|
// EXIT_INTERNAL shows an internal error message and quits the program.
|
|
|
|
#define EXIT_INTERNAL() ExitAssert("\p" __FILE__, __LINE__, NULL)
|
2022-04-10 08:09:17 +00:00
|
|
|
|
2022-11-18 01:38:03 +00:00
|
|
|
// ASSERT checks that the given condition is true. Otherwise, it displays an
|
|
|
|
// error message and quits the program.
|
2022-04-10 08:09:17 +00:00
|
|
|
#define ASSERT(p) \
|
|
|
|
do { \
|
|
|
|
if (!(p)) \
|
|
|
|
ExitAssert("\p" __FILE__, __LINE__, "\p" #p); \
|
|
|
|
} while (0)
|
|
|
|
|
2023-05-06 23:41:40 +00:00
|
|
|
// ShowMemError shows an out of memory error to the user.
|
|
|
|
void ShowMemError(void);
|
2022-04-10 08:09:17 +00:00
|
|
|
|
2023-05-06 23:41:40 +00:00
|
|
|
// ShowError shows an error alert window to the user. The error codes are
|
|
|
|
// displayed if they are not 0. If osErr is not 0, then it is displayed as well.
|
|
|
|
// Any ^1 parameters in the error messages are replaced with strParam.
|
|
|
|
void ShowError(ErrorCode err1, ErrorCode err2, short osErr,
|
|
|
|
const unsigned char *strParam);
|
2022-04-10 08:09:17 +00:00
|
|
|
|
|
|
|
#endif
|