Some times I don't like no of nested if else in kotlin. Is there any way to write better code? Am giving one example, you can choose any other example. Please share your feedback.
suspend fun setStoreImages(call: ApplicationCall) {
val storeImagesMapper = call.receive<ArrayList<StoreImageMapper>>()
val employeeEmail = getEmailFromJWT(call)
if (employeeEmail == null){
call.respond(HttpStatusCode.BadRequest, "No employee email id passed")
}else {
val errorStr = StoreApis.createStoreImages(storeImagesMapper, employeeEmail)
if (errorStr == null) {
call.respond(HttpStatusCode.Created)
} else {
call.respond(HttpStatusCode.BadRequest, errorStr)
}
}
}
Aucun commentaire:
Enregistrer un commentaire