mirror of
https://github.com/catchorg/Catch2.git
synced 2025-05-28 15:39:27 +00:00
Added support for Objective-C exceptions
This commit is contained in:
parent
371db8b42f
commit
35b31fa78a
3 changed files with 40 additions and 0 deletions
|
@ -10,6 +10,10 @@
|
|||
|
||||
#include "catch_interfaces_exception.h"
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import "Foundation/Foundation.h"
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
|
||||
|
@ -24,7 +28,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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue