Merge "Ignore exceptions when investigating failure reasons" into rvc-dev am: d907c49479
Change-Id: I4ea325edd241df77ad3c8b5a16962747c9fad966
This commit is contained in:
@@ -228,19 +228,26 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
|
|||||||
} catch (SQLiteCantOpenDatabaseException e) {
|
} catch (SQLiteCantOpenDatabaseException e) {
|
||||||
String message = String.format("Cannot open database '%s'", file);
|
String message = String.format("Cannot open database '%s'", file);
|
||||||
|
|
||||||
final Path path = FileSystems.getDefault().getPath(file);
|
try {
|
||||||
final Path dir = path.getParent();
|
// Try to diagnose for common reasons. If something fails in here, that's fine;
|
||||||
|
// just swallow the exception.
|
||||||
|
|
||||||
if (!Files.isDirectory(dir)) {
|
final Path path = FileSystems.getDefault().getPath(file);
|
||||||
message += ": Directory " + dir + " doesn't exist";
|
final Path dir = path.getParent();
|
||||||
} else if (!Files.exists(path)) {
|
|
||||||
message += ": File " + path + " doesn't exist";
|
if (!Files.isDirectory(dir)) {
|
||||||
} else if (!Files.isReadable(path)) {
|
message += ": Directory " + dir + " doesn't exist";
|
||||||
message += ": File " + path + " is not readable";
|
} else if (!Files.exists(path)) {
|
||||||
} else if (Files.isDirectory(path)) {
|
message += ": File " + path + " doesn't exist";
|
||||||
message += ": Path " + path + " is a directory";
|
} else if (!Files.isReadable(path)) {
|
||||||
} else {
|
message += ": File " + path + " is not readable";
|
||||||
message += ": Unknown reason";
|
} else if (Files.isDirectory(path)) {
|
||||||
|
message += ": Path " + path + " is a directory";
|
||||||
|
} else {
|
||||||
|
message += ": Unknown reason";
|
||||||
|
}
|
||||||
|
} catch (Throwable th) {
|
||||||
|
message += ": Unknown reason; cannot examine filesystem: " + th.getMessage();
|
||||||
}
|
}
|
||||||
throw new SQLiteCantOpenDatabaseException(message, e);
|
throw new SQLiteCantOpenDatabaseException(message, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user