Skip to content

Commit 19cedd7

Browse files
committed
Fixes a possible hard crash caused by android-upload-service sending null-pointer
1 parent 3ff0f0f commit 19cedd7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

android/src/main/java/com/vydia/UploaderModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ public void onError(Context context, UploadInfo uploadInfo, ServerResponse serve
157157
params.putInt("responseCode", serverResponse.getHttpCode());
158158
params.putString("responseBody", serverResponse.getBodyAsString());
159159
}
160-
params.putString("error", exception.getMessage());
160+
161+
// Make sure we do not try to call getMessage() on a null object
162+
if(exception){
163+
params.putString("error", exception.getMessage());
164+
}else{
165+
params.putString("error", "Unknown exception");
166+
}
167+
161168
sendEvent("error", params);
162169
}
163170

@@ -246,7 +253,6 @@ public void onCancelled(Context context, UploadInfo uploadInfo) {
246253
if (notification.hasKey("onCancelledMessage")) {
247254
notificationConfig.getCancelled().message = notification.getString("onCancelledMessage");
248255
}
249-
250256

251257
request.setNotificationConfig(notificationConfig);
252258

0 commit comments

Comments
 (0)