Kevin
02/09/2019, 1:09 AMreturn when {
filename.isNullOrBlank() -> context.error("Cannot be blank")
!File(filename).exists() -> context.error("File does not exist")
!File(filename).isFile -> context.error("Not a file")
!File(filename).canRead() -> context.error("Permission Denied")
else -> when (val code = canConnect(filename)) {
SQLiteErrorCode.SQLITE_OK -> context.success()
else -> context.error(code.message)
}
}
I only want to try to open a JDBC connection once I know it’s a valid filepath and all that, but is nesting a when
inside the else
of another when
bad form?karelpeeters
02/10/2019, 11:30 AM