2023-11-01 21:11:11 +00:00
|
|
|
// This file Copyright © Mnemosyne LLC.
|
2022-08-08 18:05:39 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-24 00:10:06 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2023-02-12 14:16:20 +00:00
|
|
|
#include <cstdlib> // for abort()
|
|
|
|
|
2023-04-16 20:34:19 +00:00
|
|
|
#include <fmt/core.h>
|
2022-01-24 00:10:06 +00:00
|
|
|
|
2023-11-03 17:03:26 +00:00
|
|
|
#include "libtransmission/tr-assert.h"
|
2022-01-24 00:10:06 +00:00
|
|
|
|
|
|
|
#if !defined(NDEBUG) || defined(TR_FORCE_ASSERTIONS)
|
|
|
|
|
|
|
|
// macOS implementation of tr_assert_report() that provides the message in the crash report
|
|
|
|
// This replaces the generic implementation of the function in tr-assert.cc
|
|
|
|
|
2022-12-18 16:23:44 +00:00
|
|
|
[[noreturn]] bool tr_assert_report(std::string_view file, long line, std::string_view message)
|
2022-01-24 00:10:06 +00:00
|
|
|
{
|
2022-04-01 23:00:51 +00:00
|
|
|
auto const full_text = fmt::format(FMT_STRING("assertion failed: {:s} ({:s}:{:d})"), message, file, line);
|
|
|
|
[NSException raise:NSInternalInconsistencyException format:@"%s", full_text.c_str()];
|
2023-02-12 14:16:20 +00:00
|
|
|
|
|
|
|
// We should not reach this anyway, but it helps mark the function as property noreturn
|
|
|
|
// (the Objective-C NSException method does not).
|
|
|
|
abort();
|
2022-01-24 00:10:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|