Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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;
Expand Down Expand Up @@ -148,6 +149,12 @@ public Task<CustomModel> getNewDownloadUrlWithExpiry(String projectNumber, Strin
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();
Expand Down Expand Up @@ -206,6 +213,8 @@ public Task<CustomModel> getCustomModelDetails(
new FirebaseMlException(
"Error reading custom model from download service: " + e.getMessage(),
FirebaseMlException.INVALID_ARGUMENT));
} catch (FirebaseMlException e) {
return Tasks.forException(e);
}
}

Expand Down