Skip to content

Commit 33f77c7

Browse files
committed
refactor: throw our MalformedURLException
1 parent 72f58c3 commit 33f77c7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

android/src/main/java/com/margelo/nitro/rive/HTTPLoader.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.margelo.nitro.rive
33
import kotlinx.coroutines.Dispatchers
44
import kotlinx.coroutines.withContext
55
import java.net.HttpURLConnection
6+
import java.net.MalformedURLException
67
import java.net.URL
78

89
sealed class HTTPLoaderException(message: String) : Exception(message) {
@@ -13,7 +14,11 @@ sealed class HTTPLoaderException(message: String) : Exception(message) {
1314

1415
object HTTPLoader {
1516
suspend fun downloadBytes(url: String): ByteArray = withContext(Dispatchers.IO) {
16-
val urlObj = URL(url)
17+
val urlObj = try {
18+
URL(url)
19+
} catch (e: MalformedURLException) {
20+
throw HTTPLoaderException.InvalidURL(url)
21+
}
1722
val connection = urlObj.openConnection() as HttpURLConnection
1823

1924
try {

0 commit comments

Comments
 (0)