If kotlin promotes safe code such as:
val currentName = "Some Guy"
getDataFromServer()?.getUsers()?.find { it.name == currentName }?.profilePicture?.let {
showPicture(it)
} ?: let {
showAddPictureButton()
}
Why there is no similar syntax for exception handling, for example using imaginary ??.
operator:
val someUserId = 123
val newName = "Cool Dude"
connectToDatabase()??.getDao<UserDao>()??.changeUserName(someUserId, newName)??.let { newUserData ->
reloadView(newUserData)
} ??: let { error ->
interpretAndHandleError(error)
}
I don't see drawbacks here. Is there any reason this is not a part of language?