From 598d7dc68c9669ec61fead880e335e59c9f74eec Mon Sep 17 00:00:00 2001 From: Lee Houghton Date: Mon, 6 Jul 2020 14:49:59 +0100 Subject: [PATCH] chore(android): improve error message when Filesystem.copy fails (#3148) --- .../com/getcapacitor/plugin/Filesystem.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java index 9cd692377..18e62b67e 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java @@ -579,23 +579,22 @@ private void _copy(PluginCall call, boolean doRename) { toObject.delete(); assert fromObject != null; - boolean modified = false; if (doRename) { - modified = fromObject.renameTo(toObject); + boolean modified = fromObject.renameTo(toObject); + if (!modified) { + call.error("Unable to rename, unknown reason"); + return; + } } else { try { copyRecursively(fromObject, toObject); - modified = true; - } catch (IOException ignored) { + } catch (IOException e) { + call.error("Unable to perform action: " + e.getLocalizedMessage()); + return; } } - if (!modified) { - call.error("Unable to perform action, unknown reason"); - return; - } - call.success(); }