Skip to content

Commit

Permalink
Merge pull request #188 from getsentry/feature/crash-reason
Browse files Browse the repository at this point in the history
Enhance value of exception with crash reason
  • Loading branch information
HazAT authored Jul 18, 2017
2 parents 7c6635b + d86df24 commit 07b79d5
Show file tree
Hide file tree
Showing 4 changed files with 3,164 additions and 1 deletion.
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

0 comments on commit 07b79d5

Please sign in to comment.