File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
platform-includes/capture-error Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,16 @@ You can capture errors with the `captureError` method. This method takes an `Err
33``` swift {tabTitle:Swift}
44import Sentry
55
6+ enum MyCustomError : Error {
7+ case myFirstIssue
8+ }
9+
10+ func thisFunctionWillThrow () throws {
11+ throw MyCustomError.myFirstIssue
12+ }
13+
614do {
7- try aMethodThatMightFail ()
15+ try thisFunctionWillThrow ()
816} catch {
917 SentrySDK.capture (error : error)
1018}
1321``` objc {tabTitle:Objective-C}
1422@import Sentry;
1523
24+ - (void )thisFunctionWillReturnAnError:(NSError **)error {
25+ * error = [ NSError errorWithDomain:@"com.example.myapp"
26+ code:1001
27+ userInfo:@{
28+ NSLocalizedDescriptionKey : @" Something went wrong."
29+ } ] ;
30+ }
31+ // ... Your code
32+
1633NSError *error = nil ;
17- [self aMethodThatMightFail : &error]
34+ [self thisFunctionWillReturnAnError : &error] ;
1835
1936if (error) {
2037 [SentrySDK captureError :error ];
You can’t perform that action at this time.
0 commit comments