https://kotlinlang.org logo
#getting-started
Title
# getting-started
z

zero_coding

08/29/2020, 2:52 PM
What does
UUID!
mean?
d

deactivateduser

08/29/2020, 2:59 PM
z

zero_coding

08/29/2020, 3:47 PM
if I pass a wrong UUID, it will throw
IllegalArgumentException
right? And how to handle it?
d

deactivateduser

08/29/2020, 4:29 PM
you need try..catch.. block for this..
j

jbnizet

08/29/2020, 4:34 PM
Yes, but that has nothing to do with the exclamation point at the end of UUID. You handle it like any other exception: either you can handle the exception (which means you can still return a correct UserMapper from your method even though the id is not a valid UUID), and in that case, you catch the exception to handle it. Or you can’t do anything about it, which means that the caller (or the caller of the caller, etc.) needs to handle this situation somehow, and in that case you simply let the exception be thrown, or catch it and throw another type of exception, more suited to your level of abstraction.
3 Views