return exception if modelname is empty
@@ -16,6 +16,7 @@ package com.google.firebase.ml.modeldownloader.internal;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.text.TextUtils;
import android.util.JsonReader;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -148,6 +149,12 @@ public class CustomModelDownloadService {
public Task<CustomModel> getCustomModelDetails(
String projectNumber, String modelName, String modelHash) {
try {
+
+ if (TextUtils.isEmpty(modelName))
+ throw new FirebaseMlException(
+ "Error cannot retrieve model from reading an empty modelName",
+ FirebaseMlException.INVALID_ARGUMENT);
+
URL url =
new URL(String.format(DOWNLOAD_MODEL_REGEX, downloadHost, projectNumber, modelName));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
@@ -206,6 +213,8 @@ public class CustomModelDownloadService {
new FirebaseMlException(
"Error reading custom model from download service: " + e.getMessage(),
FirebaseMlException.INVALID_ARGUMENT));
+ } catch (FirebaseMlException e) {
+ return Tasks.forException(e);
}
}
