Skip to content

Kotlin library hides errors if download fails #131

@weaversam8

Description

@weaversam8

Wrapping this code in a try/catch means any descriptive error message will be invisible to the developer. Instead, the library just returns an opaque false which is not useful for troubleshooting:

try {
val modelsDir = File(applicationContext.cacheDir, "models")
if (!modelsDir.exists()) modelsDir.mkdirs()
val modelFile = File(modelsDir, filename)
if (modelFile.exists()) return@withContext true
val urlConnection = URL(url).openConnection()
urlConnection.getInputStream().use { input ->
modelFile.outputStream().use { output ->
input.copyTo(output)
}
}
modelFile.exists()
} catch (e: Exception) {
false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions