Hello. How is it conventient to format an if-else ...
# codingconventions
d
Hello. How is it conventient to format an if-else like this:
Copy code
if (hasFlightsOrMinPrices(searchParams, response)) response
else throw ServerError.FlightsNotFound(key = "FlightsNotFound", userMessage = "message", debugMessage = "no flights in response")
As you can see this is a ternary-like if operator, but it has really long expressions in its branches. I currently format it like above, but other options would be:
Copy code
if (hasFlightsOrMinPrices(searchParams, response)) response else 
   throw ServerError.FlightsNotFound(key = "FlightsNotFound", userMessage = "message", debugMessage = "no flights in response")
or
Copy code
if (hasFlightsOrMinPrices(searchParams, response))
  response 
else 
  throw ServerError.FlightsNotFound(key = "FlightsNotFound", userMessage = "message", debugMessage = "no flights in response")