Skip to content

Commit 1ab8e1c

Browse files
committed
Merge pull request #251 from BoltsFramework/nlutsenko.exceptions
Deprecate BFTask automatic exception catching.
2 parents d326aa0 + f6ef4fa commit 1ab8e1c

File tree

10 files changed

+183
-24
lines changed

10 files changed

+183
-24
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ script:
3737
set -o pipefail
3838
xcodebuild test -project Bolts.xcodeproj -sdk appletvsimulator -scheme Bolts-tvOS -destination "platform=tvOS Simulator,name=Apple TV 1080p" -configuration Debug GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -c
3939
elif [ "$TEST_TYPE" = CocoaPods ]; then
40-
pod lib lint Bolts.podspec
4140
pod lib lint --use-libraries Bolts.podspec
41+
pod lib lint Bolts.podspec
4242
elif [ "$TEST_TYPE" = Carthage ]; then
4343
carthage build --no-skip-current
4444
fi

Bolts.xcodeproj/project.pbxproj

+32
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@
9696
819573EA1C2B8ECB00BFCA39 /* BFTaskCompletionSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5219900A84000BAE3F /* BFTaskCompletionSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
9797
819573EC1C2B8ECB00BFCA39 /* Bolts.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5419900A84000BAE3F /* Bolts.h */; settings = {ATTRIBUTES = (Public, ); }; };
9898
819573ED1C2B8ECB00BFCA39 /* BFCancellationToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C60AEBD1ACF08F300747DD7 /* BFCancellationToken.h */; settings = {ATTRIBUTES = (Public, ); }; };
99+
81CD062A1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
100+
81CD062B1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
101+
81CD062C1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
102+
81CD062D1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
103+
81CD062E1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
104+
81CD062F1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
105+
81CD06301CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
106+
81CD06331CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
107+
81CD06341CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
108+
81CD06351CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
109+
81CD06361CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
110+
81CD06371CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
111+
81CD06381CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
112+
81CD06391CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
99113
81D0EE7D19AFA8260000AE75 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81D0EE7C19AFA8260000AE75 /* UIKit.framework */; };
100114
81D0EE8319AFAA0E0000AE75 /* Bolts.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5419900A84000BAE3F /* Bolts.h */; settings = {ATTRIBUTES = (Public, ); }; };
101115
81D0EE8519AFAA190000AE75 /* BFTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5019900A84000BAE3F /* BFTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -274,6 +288,8 @@
274288
8178F99E1BB0F8A600AD289D /* watchOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "watchOS-Info.plist"; path = "Resources/watchOS-Info.plist"; sourceTree = "<group>"; };
275289
819573F11C2B8ECB00BFCA39 /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
276290
819573F31C2B8EF400BFCA39 /* Bolts-watchOS-Dynamic.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Bolts-watchOS-Dynamic.xcconfig"; sourceTree = "<group>"; };
291+
81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BFTask+Exceptions.h"; sourceTree = "<group>"; };
292+
81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BFTask+Exceptions.m"; sourceTree = "<group>"; };
277293
81D0EE7C19AFA8260000AE75 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
278294
81DC1A611B7A7F4000F491DC /* ExecutorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExecutorTests.m; sourceTree = "<group>"; };
279295
81E94D6A1C2B8BF200A6291E /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -428,6 +444,8 @@
428444
8103FA5519900A84000BAE3F /* Bolts.m */,
429445
8103FA5019900A84000BAE3F /* BFTask.h */,
430446
8103FA5119900A84000BAE3F /* BFTask.m */,
447+
81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */,
448+
81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */,
431449
8103FA5219900A84000BAE3F /* BFTaskCompletionSource.h */,
432450
8103FA5319900A84000BAE3F /* BFTaskCompletionSource.m */,
433451
8103FA4E19900A84000BAE3F /* BFExecutor.h */,
@@ -628,6 +646,7 @@
628646
buildActionMask = 2147483647;
629647
files = (
630648
1D5D7DBA1BE3CE8200FD67C7 /* BFWebViewAppLinkResolver.h in Headers */,
649+
81CD062B1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
631650
1D5D7DBB1BE3CE8200FD67C7 /* BFCancellationTokenRegistration.h in Headers */,
632651
1D5D7DBC1BE3CE8200FD67C7 /* BFTask.h in Headers */,
633652
1D5D7DBD1BE3CE8200FD67C7 /* BFAppLinkNavigation.h in Headers */,
@@ -655,6 +674,7 @@
655674
buildActionMask = 2147483647;
656675
files = (
657676
8178F9901BB0F87700AD289D /* BFCancellationTokenRegistration.h in Headers */,
677+
81CD062F1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
658678
8178F9911BB0F87700AD289D /* BFTask.h in Headers */,
659679
8178F9921BB0F87700AD289D /* BFCancellationTokenSource.h in Headers */,
660680
8178F9931BB0F87700AD289D /* BFExecutor.h in Headers */,
@@ -669,6 +689,7 @@
669689
buildActionMask = 2147483647;
670690
files = (
671691
819573E51C2B8ECB00BFCA39 /* BFCancellationTokenRegistration.h in Headers */,
692+
81CD06301CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
672693
819573E61C2B8ECB00BFCA39 /* BFTask.h in Headers */,
673694
819573E71C2B8ECB00BFCA39 /* BFCancellationTokenSource.h in Headers */,
674695
819573E81C2B8ECB00BFCA39 /* BFExecutor.h in Headers */,
@@ -683,6 +704,7 @@
683704
buildActionMask = 2147483647;
684705
files = (
685706
7CA39C931ADE715400DD78CC /* BFCancellationTokenRegistration.h in Headers */,
707+
81CD062C1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
686708
81D0EE8519AFAA190000AE75 /* BFTask.h in Headers */,
687709
7C60AECA1ACF1A0B00747DD7 /* BFCancellationTokenSource.h in Headers */,
688710
81D0EE8819AFAA240000AE75 /* BFExecutor.h in Headers */,
@@ -697,6 +719,7 @@
697719
buildActionMask = 2147483647;
698720
files = (
699721
81E94D5E1C2B8BF200A6291E /* BFCancellationTokenRegistration.h in Headers */,
722+
81CD062E1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
700723
81E94D5F1C2B8BF200A6291E /* BFTask.h in Headers */,
701724
81E94D601C2B8BF200A6291E /* BFCancellationTokenSource.h in Headers */,
702725
81E94D611C2B8BF200A6291E /* BFExecutor.h in Headers */,
@@ -711,6 +734,7 @@
711734
buildActionMask = 2147483647;
712735
files = (
713736
81ED94311BE1481900795F05 /* BFWebViewAppLinkResolver.h in Headers */,
737+
81CD062A1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
714738
81ED941D1BE147CF00795F05 /* BFCancellationTokenRegistration.h in Headers */,
715739
81ED941E1BE147CF00795F05 /* BFTask.h in Headers */,
716740
81ED942E1BE1481900795F05 /* BFAppLinkNavigation.h in Headers */,
@@ -738,6 +762,7 @@
738762
buildActionMask = 2147483647;
739763
files = (
740764
F5AFC9F61BA752750076E927 /* BFCancellationTokenRegistration.h in Headers */,
765+
81CD062D1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
741766
F5AFC9F71BA752750076E927 /* BFTask.h in Headers */,
742767
F5AFC9F81BA752750076E927 /* BFCancellationTokenSource.h in Headers */,
743768
F5AFC9F91BA752750076E927 /* BFExecutor.h in Headers */,
@@ -1027,6 +1052,7 @@
10271052
1D5D7DAB1BE3CE8200FD67C7 /* BFAppLinkReturnToRefererView.m in Sources */,
10281053
1D5D7DAC1BE3CE8200FD67C7 /* BFTask.m in Sources */,
10291054
1D5D7DAD1BE3CE8200FD67C7 /* Bolts.m in Sources */,
1055+
81CD06341CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
10301056
1D5D7DAE1BE3CE8200FD67C7 /* BFCancellationTokenRegistration.m in Sources */,
10311057
1D5D7DAF1BE3CE8200FD67C7 /* BFCancellationTokenSource.m in Sources */,
10321058
1D5D7DB01BE3CE8200FD67C7 /* BFMeasurementEvent.m in Sources */,
@@ -1058,6 +1084,7 @@
10581084
8178F9891BB0F87700AD289D /* BFCancellationTokenRegistration.m in Sources */,
10591085
8178F98A1BB0F87700AD289D /* BFCancellationTokenSource.m in Sources */,
10601086
8178F98B1BB0F87700AD289D /* BFExecutor.m in Sources */,
1087+
81CD06381CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
10611088
8178F98C1BB0F87700AD289D /* BFCancellationToken.m in Sources */,
10621089
);
10631090
runOnlyForDeploymentPostprocessing = 0;
@@ -1072,6 +1099,7 @@
10721099
819573DE1C2B8ECB00BFCA39 /* BFCancellationTokenRegistration.m in Sources */,
10731100
819573DF1C2B8ECB00BFCA39 /* BFCancellationTokenSource.m in Sources */,
10741101
819573E01C2B8ECB00BFCA39 /* BFExecutor.m in Sources */,
1102+
81CD06391CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
10751103
819573E11C2B8ECB00BFCA39 /* BFCancellationToken.m in Sources */,
10761104
);
10771105
runOnlyForDeploymentPostprocessing = 0;
@@ -1086,6 +1114,7 @@
10861114
81E94D571C2B8BF200A6291E /* BFCancellationTokenRegistration.m in Sources */,
10871115
81E94D581C2B8BF200A6291E /* BFCancellationTokenSource.m in Sources */,
10881116
81E94D591C2B8BF200A6291E /* BFExecutor.m in Sources */,
1117+
81CD06371CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
10891118
81E94D5A1C2B8BF200A6291E /* BFCancellationToken.m in Sources */,
10901119
);
10911120
runOnlyForDeploymentPostprocessing = 0;
@@ -1100,6 +1129,7 @@
11001129
81ED94361BE1481900795F05 /* BFAppLinkReturnToRefererView.m in Sources */,
11011130
81ED94141BE147CF00795F05 /* BFTask.m in Sources */,
11021131
81ED94151BE147CF00795F05 /* Bolts.m in Sources */,
1132+
81CD06331CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
11031133
81ED94161BE147CF00795F05 /* BFCancellationTokenRegistration.m in Sources */,
11041134
81ED94171BE147CF00795F05 /* BFCancellationTokenSource.m in Sources */,
11051135
81ED943C1BE1481900795F05 /* BFMeasurementEvent.m in Sources */,
@@ -1144,6 +1174,7 @@
11441174
7CA39C951ADE715400DD78CC /* BFCancellationTokenRegistration.m in Sources */,
11451175
7C60AECB1ACF1A0D00747DD7 /* BFCancellationTokenSource.m in Sources */,
11461176
8103FA6919900A84000BAE3F /* BFExecutor.m in Sources */,
1177+
81CD06351CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
11471178
7C60AEC91ACF1A0900747DD7 /* BFCancellationToken.m in Sources */,
11481179
);
11491180
runOnlyForDeploymentPostprocessing = 0;
@@ -1158,6 +1189,7 @@
11581189
F5AFC9EF1BA752750076E927 /* BFCancellationTokenRegistration.m in Sources */,
11591190
F5AFC9F01BA752750076E927 /* BFCancellationTokenSource.m in Sources */,
11601191
F5AFC9F11BA752750076E927 /* BFExecutor.m in Sources */,
1192+
81CD06361CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
11611193
F5AFC9F21BA752750076E927 /* BFCancellationToken.m in Sources */,
11621194
);
11631195
runOnlyForDeploymentPostprocessing = 0;

Bolts/Common/BFTask+Exceptions.h

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2016, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#pragma once
11+
12+
#import <Foundation/Foundation.h>
13+
14+
NS_ASSUME_NONNULL_BEGIN
15+
16+
/**
17+
Returns whether all instances of `BFTask` should automatically @try/@catch exceptions in continuation blocks. Default: `YES`.
18+
19+
@return Boolean value indicating whether exceptions are being caught.
20+
*/
21+
extern BOOL BFTaskCatchesExceptions(void)
22+
__attribute__((deprecated("This is temporary API and will be removed in a future release.")));
23+
24+
/**
25+
Set whether all instances of `BFTask` should automatically @try/@catch exceptions in continuation blocks. Default: `YES`.
26+
27+
@param catchExceptions Boolean value indicating whether exceptions shoudl be caught.
28+
*/
29+
extern void BFTaskSetCatchesExceptions(BOOL catchExceptions)
30+
__attribute__((deprecated("This is a temporary API and will be removed in a future release.")));
31+
32+
NS_ASSUME_NONNULL_END

Bolts/Common/BFTask+Exceptions.m

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2016, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "BFTask+Exceptions.h"
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
static BOOL taskCatchExceptions = YES;
15+
16+
BOOL BFTaskCatchesExceptions(void) {
17+
return taskCatchExceptions;
18+
}
19+
20+
void BFTaskSetCatchesExceptions(BOOL catchExceptions) {
21+
taskCatchExceptions = catchExceptions;
22+
}
23+
24+
NS_ASSUME_NONNULL_END

Bolts/Common/BFTask.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ extern NSInteger const kBFMultipleErrorsError;
2626

2727
/*!
2828
An exception that is thrown if there was multiple exceptions on <BFTask taskForCompletionOfAllTasks:>.
29+
30+
@deprecated `BFTask` exception handling is deprecated and will be removed in a future release.
2931
*/
30-
extern NSString *const BFTaskMultipleExceptionsException;
32+
extern NSString *const BFTaskMultipleExceptionsException
33+
__attribute__((deprecated("`BFTask` exception handling is deprecated and will be removed in a future release.")));
3134

3235
/*!
3336
An error userInfo key used if there were multiple errors on <BFTask taskForCompletionOfAllTasks:>.
@@ -38,8 +41,11 @@ extern NSString *const BFTaskMultipleErrorsUserInfoKey;
3841
/*!
3942
An error userInfo key used if there were multiple exceptions on <BFTask taskForCompletionOfAllTasks:>.
4043
Value type is `NSArray<NSException *> *`.
44+
45+
@deprecated `BFTask` exception handling is deprecated and will be removed in a future release.
4146
*/
42-
extern NSString *const BFTaskMultipleExceptionsUserInfoKey;
47+
extern NSString *const BFTaskMultipleExceptionsUserInfoKey
48+
__attribute__((deprecated("`BFTask` exception handling is deprecated and will be removed in a future release.")));
4349

4450
@class BFExecutor;
4551
@class BFTask;
@@ -71,8 +77,11 @@ typedef __nullable id(^BFContinuationBlock)(BFTask<ResultType> *task);
7177
/*!
7278
Creates a task that is already completed with the given exception.
7379
@param exception The exception for the task.
80+
81+
@deprecated `BFTask` exception handling is deprecated and will be removed in a future release.
7482
*/
75-
+ (instancetype)taskWithException:(NSException *)exception;
83+
+ (instancetype)taskWithException:(NSException *)exception
84+
__attribute__((deprecated("`BFTask` exception handling is deprecated and will be removed in a future release.")));
7685

7786
/*!
7887
Creates a task that is already cancelled.
@@ -143,8 +152,11 @@ typedef __nullable id(^BFContinuationBlock)(BFTask<ResultType> *task);
143152

144153
/*!
145154
The exception of a failed task.
155+
156+
@deprecated `BFTask` exception handling is deprecated and will be removed in a future release.
146157
*/
147-
@property (nullable, nonatomic, strong, readonly) NSException *exception;
158+
@property (nullable, nonatomic, strong, readonly) NSException *exception
159+
__attribute__((deprecated("`BFTask` exception handling is deprecated and will be removed in a future release.")));
148160

149161
/*!
150162
Whether this task has been cancelled.

0 commit comments

Comments
 (0)