Skip to content

Commit

Permalink
Catch UnsatisfiedLinkError when load native library (#23286)
Browse files Browse the repository at this point in the history
When the native library cannot be loaded, catch the exception so that
the logs can be parsed later on. This makes this issue a bit easier to
debug.
  • Loading branch information
cliffamzn authored and pull[bot] committed May 18, 2023
1 parent 91b997c commit a8d9e4c
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package chip.setuppayload;

import java.util.logging.Level;
import java.util.logging.Logger;

/** Parser for scanned QR code or manual entry code. */
public class SetupPayloadParser {

private static final Logger LOGGER = Logger.getLogger(SetupPayloadParser.class.getSimpleName());

/**
* Returns {@link SetupPayload} parsed from the QR code string. If an invalid element is included
* in the QRCode Parse result, SetupPayloadException occurs. Refer to {@link SetupPayload} for the
Expand Down Expand Up @@ -69,7 +74,11 @@ private native SetupPayload fetchPayloadFromManualEntryCode(
throws InvalidEntryCodeFormatException, SetupPayloadException;

static {
System.loadLibrary("SetupPayloadParser");
try {
System.loadLibrary("SetupPayloadParser");
} catch (UnsatisfiedLinkError e) {
LOGGER.log(Level.SEVERE, "Cannot load library.", e);
}
}

public static class UnrecognizedQrCodeException extends Exception {
Expand Down

0 comments on commit a8d9e4c

Please sign in to comment.