mirror of https://github.com/oxen-io/session-ios
				
				
				
			Updated to the latest libSession and updated it's error handling
							parent
							
								
									d1a4683bc3
								
							
						
					
					
						commit
						b0eec5a4c2
					
				| @ -1 +1 @@ | ||||
| Subproject commit d0b03ecf7d17e365edb077d888e926c88ef5d593 | ||||
| Subproject commit ea1b1dfcf6b0a6ad6e2359df3c296935e695afc8 | ||||
| @ -1,16 +0,0 @@ | ||||
| // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
 | ||||
| 
 | ||||
| #ifndef __CExceptionHelper_h__ | ||||
| #define __CExceptionHelper_h__ | ||||
| 
 | ||||
| #import <Foundation/Foundation.h> | ||||
| 
 | ||||
| #define noEscape __attribute__((noescape)) | ||||
| 
 | ||||
| @interface CExceptionHelper: NSObject | ||||
| 
 | ||||
| + (BOOL)performSafely:(noEscape void(^)(void))tryBlock error:(__autoreleasing NSError **)error; | ||||
| 
 | ||||
| @end | ||||
| 
 | ||||
| #endif | ||||
| @ -1,36 +0,0 @@ | ||||
| // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. | ||||
| // | ||||
| // This logic is not foolproof and may result in memory-leaks, when possible we should look to remove this | ||||
| // and use the native C++ <-> Swift interoperability coming with Swift 5.9 | ||||
| // | ||||
| // This solution was sourced from the following link, for more information please refer to this thread: | ||||
| // https://forums.swift.org/t/pitch-a-swift-representation-for-thrown-and-caught-exceptions/54583 | ||||
| 
 | ||||
| #import "CExceptionHelper.h" | ||||
| #include <exception> | ||||
| 
 | ||||
| @implementation CExceptionHelper | ||||
| 
 | ||||
| + (BOOL)performSafely:(noEscape void(^)(void))tryBlock error:(__autoreleasing NSError **)error { | ||||
|     try { | ||||
|         tryBlock(); | ||||
|         return YES; | ||||
|     } | ||||
|     catch(NSException* e) { | ||||
|         *error = [[NSError alloc] initWithDomain:e.name code:-1 userInfo:e.userInfo]; | ||||
|         return NO; | ||||
|     } | ||||
|     catch (std::exception& e) { | ||||
|         NSString* what = [NSString stringWithUTF8String: e.what()]; | ||||
|         NSDictionary* userInfo = @{NSLocalizedDescriptionKey : what}; | ||||
|         *error = [[NSError alloc] initWithDomain:@"cpp_exception" code:-2 userInfo:userInfo]; | ||||
|         return NO; | ||||
|     } | ||||
|     catch(...) { | ||||
|         NSDictionary* userInfo = @{NSLocalizedDescriptionKey:@"Other C++ exception"}; | ||||
|         *error = [[NSError alloc] initWithDomain:@"cpp_exception" code:-3 userInfo:userInfo]; | ||||
|         return NO; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @end | ||||
					Loading…
					
					
				
		Reference in New Issue