Skip to content

Commit

Permalink
Merge pull request #251 from BoltsFramework/nlutsenko.exceptions
Browse files Browse the repository at this point in the history
Deprecate BFTask automatic exception catching.
  • Loading branch information
nlutsenko committed May 21, 2016
2 parents d326aa0 + f6ef4fa commit 1ab8e1c
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ script:
set -o pipefail
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
elif [ "$TEST_TYPE" = CocoaPods ]; then
pod lib lint Bolts.podspec
pod lib lint --use-libraries Bolts.podspec
pod lib lint Bolts.podspec
elif [ "$TEST_TYPE" = Carthage ]; then
carthage build --no-skip-current
fi
Expand Down
32 changes: 32 additions & 0 deletions Bolts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@
819573EA1C2B8ECB00BFCA39 /* BFTaskCompletionSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5219900A84000BAE3F /* BFTaskCompletionSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
819573EC1C2B8ECB00BFCA39 /* Bolts.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5419900A84000BAE3F /* Bolts.h */; settings = {ATTRIBUTES = (Public, ); }; };
819573ED1C2B8ECB00BFCA39 /* BFCancellationToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C60AEBD1ACF08F300747DD7 /* BFCancellationToken.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD062A1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD062B1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD062C1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD062D1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD062E1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD062F1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD06301CEED28A00497F47 /* BFTask+Exceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
81CD06331CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81CD06341CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81CD06351CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81CD06361CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81CD06371CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81CD06381CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81CD06391CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */; };
81D0EE7D19AFA8260000AE75 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81D0EE7C19AFA8260000AE75 /* UIKit.framework */; };
81D0EE8319AFAA0E0000AE75 /* Bolts.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5419900A84000BAE3F /* Bolts.h */; settings = {ATTRIBUTES = (Public, ); }; };
81D0EE8519AFAA190000AE75 /* BFTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 8103FA5019900A84000BAE3F /* BFTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -274,6 +288,8 @@
8178F99E1BB0F8A600AD289D /* watchOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "watchOS-Info.plist"; path = "Resources/watchOS-Info.plist"; sourceTree = "<group>"; };
819573F11C2B8ECB00BFCA39 /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
819573F31C2B8EF400BFCA39 /* Bolts-watchOS-Dynamic.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Bolts-watchOS-Dynamic.xcconfig"; sourceTree = "<group>"; };
81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BFTask+Exceptions.h"; sourceTree = "<group>"; };
81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BFTask+Exceptions.m"; sourceTree = "<group>"; };
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; };
81DC1A611B7A7F4000F491DC /* ExecutorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExecutorTests.m; sourceTree = "<group>"; };
81E94D6A1C2B8BF200A6291E /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -428,6 +444,8 @@
8103FA5519900A84000BAE3F /* Bolts.m */,
8103FA5019900A84000BAE3F /* BFTask.h */,
8103FA5119900A84000BAE3F /* BFTask.m */,
81CD06291CEED28A00497F47 /* BFTask+Exceptions.h */,
81CD06321CEED2BC00497F47 /* BFTask+Exceptions.m */,
8103FA5219900A84000BAE3F /* BFTaskCompletionSource.h */,
8103FA5319900A84000BAE3F /* BFTaskCompletionSource.m */,
8103FA4E19900A84000BAE3F /* BFExecutor.h */,
Expand Down Expand Up @@ -628,6 +646,7 @@
buildActionMask = 2147483647;
files = (
1D5D7DBA1BE3CE8200FD67C7 /* BFWebViewAppLinkResolver.h in Headers */,
81CD062B1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
1D5D7DBB1BE3CE8200FD67C7 /* BFCancellationTokenRegistration.h in Headers */,
1D5D7DBC1BE3CE8200FD67C7 /* BFTask.h in Headers */,
1D5D7DBD1BE3CE8200FD67C7 /* BFAppLinkNavigation.h in Headers */,
Expand Down Expand Up @@ -655,6 +674,7 @@
buildActionMask = 2147483647;
files = (
8178F9901BB0F87700AD289D /* BFCancellationTokenRegistration.h in Headers */,
81CD062F1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
8178F9911BB0F87700AD289D /* BFTask.h in Headers */,
8178F9921BB0F87700AD289D /* BFCancellationTokenSource.h in Headers */,
8178F9931BB0F87700AD289D /* BFExecutor.h in Headers */,
Expand All @@ -669,6 +689,7 @@
buildActionMask = 2147483647;
files = (
819573E51C2B8ECB00BFCA39 /* BFCancellationTokenRegistration.h in Headers */,
81CD06301CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
819573E61C2B8ECB00BFCA39 /* BFTask.h in Headers */,
819573E71C2B8ECB00BFCA39 /* BFCancellationTokenSource.h in Headers */,
819573E81C2B8ECB00BFCA39 /* BFExecutor.h in Headers */,
Expand All @@ -683,6 +704,7 @@
buildActionMask = 2147483647;
files = (
7CA39C931ADE715400DD78CC /* BFCancellationTokenRegistration.h in Headers */,
81CD062C1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
81D0EE8519AFAA190000AE75 /* BFTask.h in Headers */,
7C60AECA1ACF1A0B00747DD7 /* BFCancellationTokenSource.h in Headers */,
81D0EE8819AFAA240000AE75 /* BFExecutor.h in Headers */,
Expand All @@ -697,6 +719,7 @@
buildActionMask = 2147483647;
files = (
81E94D5E1C2B8BF200A6291E /* BFCancellationTokenRegistration.h in Headers */,
81CD062E1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
81E94D5F1C2B8BF200A6291E /* BFTask.h in Headers */,
81E94D601C2B8BF200A6291E /* BFCancellationTokenSource.h in Headers */,
81E94D611C2B8BF200A6291E /* BFExecutor.h in Headers */,
Expand All @@ -711,6 +734,7 @@
buildActionMask = 2147483647;
files = (
81ED94311BE1481900795F05 /* BFWebViewAppLinkResolver.h in Headers */,
81CD062A1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
81ED941D1BE147CF00795F05 /* BFCancellationTokenRegistration.h in Headers */,
81ED941E1BE147CF00795F05 /* BFTask.h in Headers */,
81ED942E1BE1481900795F05 /* BFAppLinkNavigation.h in Headers */,
Expand Down Expand Up @@ -738,6 +762,7 @@
buildActionMask = 2147483647;
files = (
F5AFC9F61BA752750076E927 /* BFCancellationTokenRegistration.h in Headers */,
81CD062D1CEED28A00497F47 /* BFTask+Exceptions.h in Headers */,
F5AFC9F71BA752750076E927 /* BFTask.h in Headers */,
F5AFC9F81BA752750076E927 /* BFCancellationTokenSource.h in Headers */,
F5AFC9F91BA752750076E927 /* BFExecutor.h in Headers */,
Expand Down Expand Up @@ -1027,6 +1052,7 @@
1D5D7DAB1BE3CE8200FD67C7 /* BFAppLinkReturnToRefererView.m in Sources */,
1D5D7DAC1BE3CE8200FD67C7 /* BFTask.m in Sources */,
1D5D7DAD1BE3CE8200FD67C7 /* Bolts.m in Sources */,
81CD06341CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
1D5D7DAE1BE3CE8200FD67C7 /* BFCancellationTokenRegistration.m in Sources */,
1D5D7DAF1BE3CE8200FD67C7 /* BFCancellationTokenSource.m in Sources */,
1D5D7DB01BE3CE8200FD67C7 /* BFMeasurementEvent.m in Sources */,
Expand Down Expand Up @@ -1058,6 +1084,7 @@
8178F9891BB0F87700AD289D /* BFCancellationTokenRegistration.m in Sources */,
8178F98A1BB0F87700AD289D /* BFCancellationTokenSource.m in Sources */,
8178F98B1BB0F87700AD289D /* BFExecutor.m in Sources */,
81CD06381CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
8178F98C1BB0F87700AD289D /* BFCancellationToken.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -1072,6 +1099,7 @@
819573DE1C2B8ECB00BFCA39 /* BFCancellationTokenRegistration.m in Sources */,
819573DF1C2B8ECB00BFCA39 /* BFCancellationTokenSource.m in Sources */,
819573E01C2B8ECB00BFCA39 /* BFExecutor.m in Sources */,
81CD06391CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
819573E11C2B8ECB00BFCA39 /* BFCancellationToken.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -1086,6 +1114,7 @@
81E94D571C2B8BF200A6291E /* BFCancellationTokenRegistration.m in Sources */,
81E94D581C2B8BF200A6291E /* BFCancellationTokenSource.m in Sources */,
81E94D591C2B8BF200A6291E /* BFExecutor.m in Sources */,
81CD06371CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
81E94D5A1C2B8BF200A6291E /* BFCancellationToken.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -1100,6 +1129,7 @@
81ED94361BE1481900795F05 /* BFAppLinkReturnToRefererView.m in Sources */,
81ED94141BE147CF00795F05 /* BFTask.m in Sources */,
81ED94151BE147CF00795F05 /* Bolts.m in Sources */,
81CD06331CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
81ED94161BE147CF00795F05 /* BFCancellationTokenRegistration.m in Sources */,
81ED94171BE147CF00795F05 /* BFCancellationTokenSource.m in Sources */,
81ED943C1BE1481900795F05 /* BFMeasurementEvent.m in Sources */,
Expand Down Expand Up @@ -1144,6 +1174,7 @@
7CA39C951ADE715400DD78CC /* BFCancellationTokenRegistration.m in Sources */,
7C60AECB1ACF1A0D00747DD7 /* BFCancellationTokenSource.m in Sources */,
8103FA6919900A84000BAE3F /* BFExecutor.m in Sources */,
81CD06351CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
7C60AEC91ACF1A0900747DD7 /* BFCancellationToken.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -1158,6 +1189,7 @@
F5AFC9EF1BA752750076E927 /* BFCancellationTokenRegistration.m in Sources */,
F5AFC9F01BA752750076E927 /* BFCancellationTokenSource.m in Sources */,
F5AFC9F11BA752750076E927 /* BFExecutor.m in Sources */,
81CD06361CEED2BC00497F47 /* BFTask+Exceptions.m in Sources */,
F5AFC9F21BA752750076E927 /* BFCancellationToken.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
32 changes: 32 additions & 0 deletions Bolts/Common/BFTask+Exceptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#pragma once

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
Returns whether all instances of `BFTask` should automatically @try/@catch exceptions in continuation blocks. Default: `YES`.
@return Boolean value indicating whether exceptions are being caught.
*/
extern BOOL BFTaskCatchesExceptions(void)
__attribute__((deprecated("This is temporary API and will be removed in a future release.")));

/**
Set whether all instances of `BFTask` should automatically @try/@catch exceptions in continuation blocks. Default: `YES`.
@param catchExceptions Boolean value indicating whether exceptions shoudl be caught.
*/
extern void BFTaskSetCatchesExceptions(BOOL catchExceptions)
__attribute__((deprecated("This is a temporary API and will be removed in a future release.")));

NS_ASSUME_NONNULL_END
24 changes: 24 additions & 0 deletions Bolts/Common/BFTask+Exceptions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "BFTask+Exceptions.h"

NS_ASSUME_NONNULL_BEGIN

static BOOL taskCatchExceptions = YES;

BOOL BFTaskCatchesExceptions(void) {
return taskCatchExceptions;
}

void BFTaskSetCatchesExceptions(BOOL catchExceptions) {
taskCatchExceptions = catchExceptions;
}

NS_ASSUME_NONNULL_END
20 changes: 16 additions & 4 deletions Bolts/Common/BFTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ extern NSInteger const kBFMultipleErrorsError;

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

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

@class BFExecutor;
@class BFTask;
Expand Down Expand Up @@ -71,8 +77,11 @@ typedef __nullable id(^BFContinuationBlock)(BFTask<ResultType> *task);
/*!
Creates a task that is already completed with the given exception.
@param exception The exception for the task.
@deprecated `BFTask` exception handling is deprecated and will be removed in a future release.
*/
+ (instancetype)taskWithException:(NSException *)exception;
+ (instancetype)taskWithException:(NSException *)exception
__attribute__((deprecated("`BFTask` exception handling is deprecated and will be removed in a future release.")));

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

/*!
The exception of a failed task.
@deprecated `BFTask` exception handling is deprecated and will be removed in a future release.
*/
@property (nullable, nonatomic, strong, readonly) NSException *exception;
@property (nullable, nonatomic, strong, readonly) NSException *exception
__attribute__((deprecated("`BFTask` exception handling is deprecated and will be removed in a future release.")));

/*!
Whether this task has been cancelled.
Expand Down
Loading

0 comments on commit 1ab8e1c

Please sign in to comment.