Skip to content

Commit

Permalink
Merge pull request #253 from privacybydesign/android-native-errors
Browse files Browse the repository at this point in the history
Chore: include the cause of Android key store exceptions in Sentry reports
  • Loading branch information
ivard authored Nov 6, 2023
2 parents f26ee25 + 2bc7c5c commit 7711118
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed
- Include the cause of Android key store exceptions in Sentry reports

### Fixed
- Stacktraces of native Android errors not parsed correctly

## [7.5.2] - 2023-10-26
### Fixed
- IRMA session gets stuck on loading spinner when user confirms PIN code (fixed by updating irmago to 0.14.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import java.security.GeneralSecurityException;
import java.util.Arrays;

import org.json.JSONObject;
import org.json.JSONException;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
Expand Down Expand Up @@ -40,8 +43,24 @@ public IrmaMobileBridge(Context context, Activity activity, MethodChannel channe
new ECDSA(context), aesKey);
this.debug = (pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
} catch (GeneralSecurityException | IOException | PackageManager.NameNotFoundException e) {
this.nativeError = String.format("{\"Exception\":\"%s\",\"Stack\":\"%s\",\"Fatal\":true}", e.toString(),
Arrays.toString(e.getStackTrace()));
String exception = e.toString();
Throwable cause = e.getCause();
while (cause != null) {
exception += "\nCaused by: " + cause.toString();
cause = cause.getCause();
}
String[] stackTrace = Arrays.stream(e.getStackTrace()).map(StackTraceElement::toString).toArray(String[]::new);

JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("Exception", exception);
jsonObject.put("Stack", String.join("\n", stackTrace));
jsonObject.put("Fatal", true);
this.nativeError = jsonObject.toString();
} catch (JSONException jsonException) {
this.nativeError = String.format("{\"Exception\":\"%s\",\"Stack\":\"\",\"Fatal\":true}",
"Unable to parse Java exception");
}
}
}

Expand Down

0 comments on commit 7711118

Please sign in to comment.