51 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
 | |
| #if !defined(BAD_APPLE_OS_EXCEPTION_INCLUDED)
 | |
| #define BAD_APPLE_OS_EXCEPTION_INCLUDED
 | |
| 
 | |
| #include <cstdlib>
 | |
| #include "os/panic.hpp"
 | |
| 
 | |
| #if defined(__cpp_exceptions)
 | |
| #define __ba_throw throw
 | |
| #else
 | |
| #define __ba_throw ba::impl::gAbortHelper(__FILE__, __LINE__) =
 | |
| #endif
 | |
| 
 | |
| namespace std
 | |
| {
 | |
| class exception
 | |
| {
 | |
| public:
 | |
|     virtual ~exception() noexcept = default;
 | |
|     virtual const char* what() const noexcept;
 | |
| };
 | |
| }
 | |
| 
 | |
| #if !defined(__cpp_exceptions)
 | |
| namespace ba::impl
 | |
| {
 | |
| struct ExceptionAbortHelper
 | |
| {
 | |
| private:
 | |
|     const char* mFile = "<unknown>";
 | |
|     int mLine = -1;
 | |
| public:
 | |
|     [[noreturn]] ExceptionAbortHelper& operator=(const std::exception& ex) noexcept
 | |
|     {
 | |
|         panicf("Uncaught exception with message \"%s\" at %s:%d.", ex.what(), mFile, mLine);
 | |
|     }
 | |
| 
 | |
|     ExceptionAbortHelper& operator()(const char* file, int line) noexcept
 | |
|     {
 | |
|         mFile = file;
 | |
|         mLine = line;
 | |
|         return *this;
 | |
|     }
 | |
| };
 | |
| 
 | |
| extern ExceptionAbortHelper gAbortHelper;
 | |
| }
 | |
| #endif // !defined(__cpp_exceptions)
 | |
| 
 | |
| #endif // !defined(BAD_APPLE_OS_EXCEPTION_INCLUDED)
 |