George
11/16/2022, 2:07 PMorThrow or it's ok to omit it? For example:
private val CspAccount.retrieveAuthenticatedDevice: CspDevice
get() = this.authenticatedDevice.getOrElse {
throw WebApplicationException(
"Authenticated device for account: ${this.number} was not found",
Response.Status.UNAUTHORIZED
)
}
It would be better if i renamed it to getAutheticatedDeviceOrThrow()? Thanks in advance for any answers !mbonnin
11/16/2022, 2:09 PMaccount.authenticatedDeviceOrThrowStarr
11/16/2022, 2:13 PMGiorgos Makris
11/16/2022, 2:14 PMorThrow part as it is. If you wanted to omit it i would expect the return type to be Result<CspDevice>Klitos Kyriacou
11/16/2022, 2:26 PMMap.getValue() - it's not getValueOrThrow. I would therefore not add OrThrow.Starr
11/16/2022, 2:27 PMgetValue is for consistency with Java, or for compatibility with delegatesKlitos Kyriacou
11/16/2022, 2:34 PMfun <K, V> Map<K, V>.getValue(key: K): V - this is unrelated to delegates, and I don't see any consistency with Java, since the Java Map interface doesn't have a "get" that throws.