Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2012-05-21 21:51:16 +0100
committerPhil Nash2012-05-21 21:51:16 +0100
commit35b31fa78a74abc4f9e3ef31dd140b03935ca20c (patch)
treed2fcd4bc24b65131e240627bf4869991a1c10e1e /include
parent371db8b42fb2171ea2ab542a9875ddf4e3e8b8ea (diff)
downloadcatch3-35b31fa78a74abc4f9e3ef31dd140b03935ca20c.tar.gz
Added support for Objective-C exceptions
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_exception_translator_registry.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/internal/catch_exception_translator_registry.hpp b/include/internal/catch_exception_translator_registry.hpp
index e80142f8..55a20713 100644
--- a/include/internal/catch_exception_translator_registry.hpp
+++ b/include/internal/catch_exception_translator_registry.hpp
@@ -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();