Skip to content

Commit

Permalink
RollbarSwift: addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akornich committed Mar 16, 2021
1 parent 68099be commit e9736c9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Demos/macosAppSwift/macosAppSwift/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func handleSwiftError() {
self.generateObjCException();
}

print("Guearded execution succeeded: \(success).")
print("Guarded execution succeeded: \(success).")
}

func createGuard() -> RollbarExceptionGuard {
Expand Down
55 changes: 28 additions & 27 deletions RollbarSwift/Sources/RollbarSwift/RollbarExceptionGuard.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,52 @@
#import "RollbarExceptionGuard.h"
#import "RollbarTryCatch.h"

@implementation RollbarExceptionGuard {
@implementation RollbarExceptionGuard {
@private
RollbarLogger *logger;
}

-(BOOL)tryExecute:(nonnull void(NS_NOESCAPE^)(void))block {

NSError *error = nil;
return [self execute:block error:&error];
}

-(BOOL)execute:(nonnull void(NS_NOESCAPE^)(void))tryBlock
error:(__autoreleasing NSError * _Nullable * _Nullable)error {
error:(__autoreleasing NSError * _Nullable * _Nullable)error {

__block BOOL success = NO;
__block NSError* exceptionError = nil;

[RollbarTryCatch try:^(void) {

tryBlock();
success = YES;
}
catch:^(NSException *exception) {

exceptionError = [self convertException:exception];

if (nil != self->logger) {

tryBlock();
success = YES;
}
catch:^(NSException *exception) {

exceptionError = [self convertException:exception];

if (nil != self->logger) {

[self->logger log:RollbarLevel_Critical
exception:exception
data:nil
context:RollbarExceptionGuard.className
];

[self->logger log:RollbarLevel_Critical
error:exceptionError
data:nil
context:RollbarExceptionGuard.className
];
}

success = NO;
}
finally:^{
[self->logger log:RollbarLevel_Critical
exception:exception
data:nil
context:RollbarExceptionGuard.className
];

[self->logger log:RollbarLevel_Critical
error:exceptionError
data:nil
context:RollbarExceptionGuard.className
];
}

success = NO;
}
finally:^{

}
];

*error = exceptionError;
Expand Down

0 comments on commit e9736c9

Please sign in to comment.