Skip to content

Commit c8ae80e

Browse files
authored
Add Cloud Code custom error playground example (#167)
1 parent 457ef7c commit c8ae80e

File tree

6 files changed

+47
-12
lines changed

6 files changed

+47
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Parse-Swift Changelog
22

33
### main
4-
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.8.1...main)
4+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.8.2...main)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
### 1.8.2
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.8.1...1.8.2)
9+
710
__Improvements__
811
- Ensure pipeline and fields are checked when comparing queries ([#163](https://github.com/parse-community/Parse-Swift/pull/163)), thanks to [Corey Baker](https://github.com/cbaker6).
912
- Allow custom error codes to be thrown from Cloud Functions ([#165](https://github.com/parse-community/Parse-Swift/pull/165)), thanks to [Daniel Blyth](https://github.com/dblythy).

ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,38 @@ cloud.runFunction { result in
4343
}
4444
}
4545

46+
/*: Assuming you have the Cloud Function named "testCloudCode" on your parse-server.
47+
You can catch custom errors created in Cloud Code:
48+
// main.js
49+
Parse.Cloud.define("testCloudCode", async() => {
50+
throw new Parse.Error(3000, "cloud has an error on purpose.");
51+
});
52+
*/
53+
let cloudError = Cloud(functionJobName: "testCloudCode")
54+
55+
cloudError.runFunction { result in
56+
switch result {
57+
case .success:
58+
assertionFailure("Should have thrown a custom error")
59+
case .failure(let error):
60+
switch error.code {
61+
case .other:
62+
guard let otherCode = error.otherCode else {
63+
assertionFailure("Should have unwrapped otherCode")
64+
return
65+
}
66+
switch otherCode {
67+
case 3000:
68+
print("Received Cloud Code error: \(error)")
69+
default:
70+
assertionFailure("Should have received code \"3000\"")
71+
}
72+
default:
73+
assertionFailure("Should have been case \"other\"")
74+
}
75+
}
76+
}
77+
4678
//: Jobs can be run the same way by using the method `startJob()`.
4779

4880
//: Saving objects with context for beforeSave, afterSave, etc.

ParseSwift.playground/contents.xcplayground

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
<page name='15 - Custom ObjectId'/>
1919
<page name='16 - Analytics'/>
2020
</pages>
21-
</playground>
21+
</playground>

ParseSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ParseSwift"
3-
s.version = "1.8.1"
3+
s.version = "1.8.2"
44
s.summary = "Parse Pure Swift SDK"
55
s.homepage = "https://github.com/parse-community/Parse-Swift"
66
s.authors = {

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@
24332433
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
24342434
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
24352435
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2436-
MARKETING_VERSION = 1.8.1;
2436+
MARKETING_VERSION = 1.8.2;
24372437
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
24382438
PRODUCT_NAME = ParseSwift;
24392439
SKIP_INSTALL = YES;
@@ -2457,7 +2457,7 @@
24572457
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
24582458
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
24592459
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2460-
MARKETING_VERSION = 1.8.1;
2460+
MARKETING_VERSION = 1.8.2;
24612461
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
24622462
PRODUCT_NAME = ParseSwift;
24632463
SKIP_INSTALL = YES;
@@ -2523,7 +2523,7 @@
25232523
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
25242524
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
25252525
MACOSX_DEPLOYMENT_TARGET = 10.13;
2526-
MARKETING_VERSION = 1.8.1;
2526+
MARKETING_VERSION = 1.8.2;
25272527
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
25282528
PRODUCT_NAME = ParseSwift;
25292529
SDKROOT = macosx;
@@ -2549,7 +2549,7 @@
25492549
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
25502550
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
25512551
MACOSX_DEPLOYMENT_TARGET = 10.13;
2552-
MARKETING_VERSION = 1.8.1;
2552+
MARKETING_VERSION = 1.8.2;
25532553
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
25542554
PRODUCT_NAME = ParseSwift;
25552555
SDKROOT = macosx;
@@ -2696,7 +2696,7 @@
26962696
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
26972697
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26982698
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2699-
MARKETING_VERSION = 1.8.1;
2699+
MARKETING_VERSION = 1.8.2;
27002700
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
27012701
MTL_FAST_MATH = YES;
27022702
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
@@ -2725,7 +2725,7 @@
27252725
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
27262726
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
27272727
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2728-
MARKETING_VERSION = 1.8.1;
2728+
MARKETING_VERSION = 1.8.2;
27292729
MTL_FAST_MATH = YES;
27302730
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
27312731
PRODUCT_NAME = ParseSwift;
@@ -2752,7 +2752,7 @@
27522752
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
27532753
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
27542754
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2755-
MARKETING_VERSION = 1.8.1;
2755+
MARKETING_VERSION = 1.8.2;
27562756
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
27572757
MTL_FAST_MATH = YES;
27582758
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
@@ -2780,7 +2780,7 @@
27802780
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
27812781
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
27822782
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2783-
MARKETING_VERSION = 1.8.1;
2783+
MARKETING_VERSION = 1.8.2;
27842784
MTL_FAST_MATH = YES;
27852785
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
27862786
PRODUCT_NAME = ParseSwift;

Scripts/jazzy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bundle exec jazzy \
55
--author_url http://parseplatform.org \
66
--github_url https://github.com/parse-community/Parse-Swift \
77
--root-url http://parseplatform.org/Parse-Swift/api/ \
8-
--module-version 1.8.1 \
8+
--module-version 1.8.2 \
99
--theme fullwidth \
1010
--skip-undocumented \
1111
--output ./docs/api \

0 commit comments

Comments
 (0)