Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance value of exception with crash reason #188

Merged
merged 3 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ gem install fastlane

if [ "$LANE" = "lint" ];
then
if [ "$TRAVIS_PULL_REQUEST" != "false" ];
then
echo "We don't run linter for PRs, because Danger!"
exit 0;
fi
gem install danger
gem install danger-swiftlint
brew update
Expand Down
23 changes: 22 additions & 1 deletion Sources/Sentry/SentryKSCrashReportConverter.m
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ - (SentryThread *)crashedThread {
type:[exceptionReason substringWithRange:NSMakeRange(0, match.location)]];
}
}


[self enhanceValueFromNotableAddresses:exception];
exception.mechanism = [self extractMechanism];
exception.thread = [self crashedThread];
if (nil != self.diagnosis && self.diagnosis.length > 0) {
Expand All @@ -317,6 +318,26 @@ - (SentryThread *)crashedThread {
return @[exception];
}

- (void)enhanceValueFromNotableAddresses:(SentryException *)exception {
NSDictionary *crashedThread = [self.threads objectAtIndex:self.crashedThreadIndex];
NSDictionary *notableAddresses = [crashedThread objectForKey:@"notable_addresses"];
NSMutableOrderedSet *reasons = [[NSMutableOrderedSet alloc] init];
if (nil != notableAddresses) {
for(id key in notableAddresses) {
NSDictionary *content = [notableAddresses objectForKey:key];
if ([[content objectForKey:@"type"] isEqualToString:@"string"]) {
// if there are less than 3 slashes it shouldn't be a filepath
if ([[[content objectForKey:@"value"] componentsSeparatedByString:@"/"] count] < 3) {
[reasons addObject:[content objectForKey:@"value"]];
}
}
}
}
if (reasons.count > 0) {
exception.value = [[[reasons array] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] componentsJoinedByString:@" | "];
}
}

- (NSDictionary<NSString *, id> *)extractMechanism {
NSMutableDictionary<NSString *, id> *mechanism = [NSMutableDictionary new];
// This is important we want both signal an mach in mechanism
Expand Down
Loading