Response
is a sealed class. A response can be either Success
or Error
and nothing else. A Success
encapsulatesData
. An Error
encapsulates Exception
.
The function getAnswer
takes response as a parameter and if this response is Success
returns the data-id else the exception message.
Let’s test it.