Native: add KotlinThrowable.asError() to the generated Obj-C framework
This method can be useful when overriding a throwing Kotlin method in Swift or Obj-C. In this case, a user can call asError to wrap Kotlin exception to (NS)Error and then throw it to Kotlin, which will unwrap it back. ^KT-45127 Fixed
This commit is contained in:
committed by
Space
parent
c988ecf59b
commit
d531df1643
@@ -778,6 +778,44 @@ __attribute__((swift_name("OverrideMethodsOfAnyKt")))
|
||||
+ (BOOL)testObj:(id)obj other:(id)other swift:(BOOL)swift error:(NSError * _Nullable * _Nullable)error __attribute__((swift_name("test(obj:other:swift:)")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("ThrowableAsError")))
|
||||
@interface KtThrowableAsError : KtKotlinThrowable
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
|
||||
- (instancetype)initWithCause:(KtKotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
|
||||
- (instancetype)initWithMessage:(NSString * _Nullable)message cause:(KtKotlinThrowable * _Nullable)cause __attribute__((swift_name("init(message:cause:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
|
||||
@end;
|
||||
|
||||
__attribute__((swift_name("ThrowsThrowableAsError")))
|
||||
@protocol KtThrowsThrowableAsError
|
||||
@required
|
||||
|
||||
/**
|
||||
@note This method converts all Kotlin exceptions to errors.
|
||||
*/
|
||||
- (BOOL)throwErrorAndReturnError:(NSError * _Nullable * _Nullable)error __attribute__((swift_name("throwError()")));
|
||||
@end;
|
||||
|
||||
__attribute__((swift_name("ThrowsThrowableAsErrorSuspend")))
|
||||
@protocol KtThrowsThrowableAsErrorSuspend
|
||||
@required
|
||||
|
||||
/**
|
||||
@note This method converts instances of CancellationException to errors.
|
||||
Other uncaught Kotlin exceptions are fatal.
|
||||
*/
|
||||
- (void)throwErrorWithCompletionHandler:(void (^)(KtKotlinUnit * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("throwError(completionHandler:)")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("ThrowableAsErrorKt")))
|
||||
@interface KtThrowableAsErrorKt : KtBase
|
||||
+ (KtThrowableAsError * _Nullable)callAndCatchThrowableAsErrorThrowsThrowableAsError:(id<KtThrowsThrowableAsError>)throwsThrowableAsError __attribute__((swift_name("callAndCatchThrowableAsError(throwsThrowableAsError:)")));
|
||||
+ (KtThrowableAsError * _Nullable)callAndCatchThrowableAsErrorSuspendThrowsThrowableAsErrorSuspend:(id<KtThrowsThrowableAsErrorSuspend>)throwsThrowableAsErrorSuspend __attribute__((swift_name("callAndCatchThrowableAsErrorSuspend(throwsThrowableAsErrorSuspend:)")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("ThrowsEmptyKt")))
|
||||
@interface KtThrowsEmptyKt : KtBase
|
||||
|
||||
Reference in New Issue
Block a user