Skip to content

Commit 598d7dc

Browse files
authored
chore(android): improve error message when Filesystem.copy fails (#3148)
1 parent 8651ef1 commit 598d7dc

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,23 +579,22 @@ private void _copy(PluginCall call, boolean doRename) {
579579
toObject.delete();
580580

581581
assert fromObject != null;
582-
boolean modified = false;
583582

584583
if (doRename) {
585-
modified = fromObject.renameTo(toObject);
584+
boolean modified = fromObject.renameTo(toObject);
585+
if (!modified) {
586+
call.error("Unable to rename, unknown reason");
587+
return;
588+
}
586589
} else {
587590
try {
588591
copyRecursively(fromObject, toObject);
589-
modified = true;
590-
} catch (IOException ignored) {
592+
} catch (IOException e) {
593+
call.error("Unable to perform action: " + e.getLocalizedMessage());
594+
return;
591595
}
592596
}
593597

594-
if (!modified) {
595-
call.error("Unable to perform action, unknown reason");
596-
return;
597-
}
598-
599598
call.success();
600599
}
601600

0 commit comments

Comments
 (0)