File tree Expand file tree Collapse file tree
android/src/main/java/com/margelo/nitro/rive Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.margelo.nitro.rive
33import kotlinx.coroutines.Dispatchers
44import kotlinx.coroutines.withContext
55import java.net.HttpURLConnection
6+ import java.net.MalformedURLException
67import java.net.URL
78
89sealed class HTTPLoaderException (message : String ) : Exception(message) {
@@ -13,7 +14,11 @@ sealed class HTTPLoaderException(message: String) : Exception(message) {
1314
1415object 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 {
You can’t perform that action at this time.
0 commit comments