2
0
mirror of synced 2025-02-23 03:28:25 +00:00

[android][storage] Prevent crash if the exception isn’t a StorageException

This commit is contained in:
Chris Bianca 2017-05-18 11:49:27 +01:00
parent 0151f6cca3
commit 9bf1de023d

View File

@ -571,49 +571,54 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
String message = exception.getMessage();
try {
StorageException storageException = (StorageException) exception;
if (exception instanceof StorageException) {
StorageException storageException = (StorageException) exception;
switch (storageException.getErrorCode()) {
case StorageException.ERROR_UNKNOWN:
code = "storage/unknown";
message = "An unknown error has occurred.";
break;
case StorageException.ERROR_OBJECT_NOT_FOUND:
code = "storage/object-not-found";
message = "No object exists at the desired reference.";
break;
case StorageException.ERROR_BUCKET_NOT_FOUND:
code = "storage/bucket-not-found";
message = "No bucket is configured for Firebase Storage.";
break;
case StorageException.ERROR_PROJECT_NOT_FOUND:
code = "storage/project-not-found";
message = "No project is configured for Firebase Storage.";
break;
case StorageException.ERROR_QUOTA_EXCEEDED:
code = "storage/quota-exceeded";
message = "Quota on your Firebase Storage bucket has been exceeded.";
break;
case StorageException.ERROR_NOT_AUTHENTICATED:
code = "storage/unauthenticated";
message = "User is unauthenticated. Authenticate and try again.";
break;
case StorageException.ERROR_NOT_AUTHORIZED:
code = "storage/unauthorized";
message = "User is not authorized to perform the desired action.";
break;
case StorageException.ERROR_RETRY_LIMIT_EXCEEDED:
code = "storage/retry-limit-exceeded";
message = "The maximum time limit on an operation (upload, download, delete, etc.) has been exceeded.";
break;
case StorageException.ERROR_INVALID_CHECKSUM:
code = "storage/non-matching-checksum";
message = "File on the client does not match the checksum of the file received by the server.";
break;
case StorageException.ERROR_CANCELED:
code = "storage/cancelled";
message = "User cancelled the operation.";
break;
switch (storageException.getErrorCode()) {
case StorageException.ERROR_UNKNOWN:
code = "storage/unknown";
message = "An unknown error has occurred.";
break;
case StorageException.ERROR_OBJECT_NOT_FOUND:
code = "storage/object-not-found";
message = "No object exists at the desired reference.";
break;
case StorageException.ERROR_BUCKET_NOT_FOUND:
code = "storage/bucket-not-found";
message = "No bucket is configured for Firebase Storage.";
break;
case StorageException.ERROR_PROJECT_NOT_FOUND:
code = "storage/project-not-found";
message = "No project is configured for Firebase Storage.";
break;
case StorageException.ERROR_QUOTA_EXCEEDED:
code = "storage/quota-exceeded";
message = "Quota on your Firebase Storage bucket has been exceeded.";
break;
case StorageException.ERROR_NOT_AUTHENTICATED:
code = "storage/unauthenticated";
message = "User is unauthenticated. Authenticate and try again.";
break;
case StorageException.ERROR_NOT_AUTHORIZED:
code = "storage/unauthorized";
message = "User is not authorized to perform the desired action.";
break;
case StorageException.ERROR_RETRY_LIMIT_EXCEEDED:
code = "storage/retry-limit-exceeded";
message = "The maximum time limit on an operation (upload, download, delete, etc.) has been exceeded.";
break;
case StorageException.ERROR_INVALID_CHECKSUM:
code = "storage/non-matching-checksum";
message = "File on the client does not match the checksum of the file received by the server.";
break;
case StorageException.ERROR_CANCELED:
code = "storage/cancelled";
message = "User cancelled the operation.";
break;
}
} else {
code = "storage/unknown";
message = "An unknown error has occurred.";
}
} finally {
promise.reject(code, message, exception);