https://kotlinlang.org logo
#ktor
Title
# ktor
r

rebok

03/12/2024, 9:55 PM
Is there a way to check does a domain exist or catch error related to the domain not existing in ktor?
a

Aleksei Tirman [JB]

03/13/2024, 8:12 AM
Do you mean to determine if a host name could be resolved?
r

rebok

03/13/2024, 8:13 AM
Yes
a

Aleksei Tirman [JB]

03/13/2024, 8:17 AM
The simplest way is to make a request and catch one of the exceptions thrown due to of the host name resolution error, for example,
UnresolvedAddressException
or
UnknownHostException
. The actual exception type depends on the client engine and the platform.
r

rebok

03/13/2024, 8:17 AM
What exception is used on the JVM?
a

Aleksei Tirman [JB]

03/13/2024, 8:18 AM
For example,
UnresolvedAddressException
or
UnknownHostException
. You can make a request to non-existent host to see what type exception is thrown.
r

rebok

03/13/2024, 8:19 AM
Thanks for the answer