diff --git a/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/NativeBugsnagPerformanceImpl.java b/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/NativeBugsnagPerformanceImpl.java index 8ee21b33f..0c7e94049 100644 --- a/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/NativeBugsnagPerformanceImpl.java +++ b/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/NativeBugsnagPerformanceImpl.java @@ -143,13 +143,20 @@ void ls(String path, Promise promise) { void mkdir(String path, Promise promise) { Log.w(TAG, "mkdir start " + path); try { - boolean result = new File(path).mkdirs(); + File file = new File(path); + if (file.exists()) { + Log.w(TAG, "mkdir already exists " + path); + promise.reject(new Exception("EEXIST", "Already exists.")); + return; + } + + boolean result = file.mkdirs(); if (result) { Log.w(TAG, "mkdir true " + path); promise.resolve(path); } else { Log.w(TAG, "mkdir false " + path); - promise.reject(new Exception("Failed to create directory")); + promise.reject(new Exception("EPERM", "Failed to create directory ")); } } catch(Exception e) { Log.w(TAG, "mkdir exception " + e.toString());