Skip to content

Commit 2e79028

Browse files
authored
fix: use promiseWrapper for all rejections in pick, pickDirectory, and saveDocument (#896)
1 parent c47d239 commit 2e79028

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.changeset/perfect-ways-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-native-documents/picker": patch
3+
---
4+
5+
fix: use promiseWrapper for all rejections in pick, pickDirectory, and saveDocument

packages/document-picker/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
9696
val intent = IntentFactory.getPickIntent(options)
9797
currentActivity.startActivityForResult(intent, PICK_FILES_REQUEST_CODE)
9898
} catch (e: ActivityNotFoundException) {
99-
promise.reject(UNABLE_TO_OPEN_FILE_TYPE, e)
99+
promiseWrapper.reject(UNABLE_TO_OPEN_FILE_TYPE, e)
100100
} catch (e: Exception) {
101-
promise.reject(E_OTHER_PRESENTING_ERROR, e)
101+
promiseWrapper.reject(E_OTHER_PRESENTING_ERROR, e)
102102
}
103103
}
104104

@@ -134,9 +134,9 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
134134
}
135135
currentActivity.startActivityForResult(intent, SAVE_DOC_REQUEST_CODE)
136136
} catch (e: ActivityNotFoundException) {
137-
promise.reject(UNABLE_TO_OPEN_FILE_TYPE, e)
137+
promiseWrapper.reject(UNABLE_TO_OPEN_FILE_TYPE, e)
138138
} catch (e: Exception) {
139-
promise.reject(E_OTHER_PRESENTING_ERROR, e)
139+
promiseWrapper.reject(E_OTHER_PRESENTING_ERROR, e)
140140
}
141141
}
142142

@@ -163,9 +163,9 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
163163
// TODO option for extra task on stack?
164164
currentActivity.startActivityForResult(intent, PICK_DIR_REQUEST_CODE)
165165
} catch (e: ActivityNotFoundException) {
166-
promise.reject(UNABLE_TO_OPEN_FILE_TYPE, e)
166+
promiseWrapper.reject(UNABLE_TO_OPEN_FILE_TYPE, e)
167167
} catch (e: Exception) {
168-
promise.reject(E_OTHER_PRESENTING_ERROR, e)
168+
promiseWrapper.reject(E_OTHER_PRESENTING_ERROR, e)
169169
}
170170
}
171171

0 commit comments

Comments
 (0)