mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Added support for Objective-C exceptions
This commit is contained in:
@@ -3157,6 +3157,10 @@ namespace Catch {
|
||||
|
||||
// #included from: catch_exception_translator_registry.hpp
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import "Foundation/Foundation.h"
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
|
||||
@@ -3171,7 +3175,17 @@ namespace Catch {
|
||||
|
||||
virtual std::string translateActiveException() const {
|
||||
try {
|
||||
#ifdef __OBJC__
|
||||
// In Objective-C try objective-c exceptions first
|
||||
@try {
|
||||
throw;
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
return toString( [exception description] );
|
||||
}
|
||||
#else
|
||||
throw;
|
||||
#endif
|
||||
}
|
||||
catch( std::exception& ex ) {
|
||||
return ex.what();
|
||||
|
Reference in New Issue
Block a user