object MyRealMainObj extends App { println( Try(1) .map(doOne) .map(doTwo) ) def doOne(i: Int): Int = i + 1; throw new RuntimeException(\"failed
wrap the code inside curly braces like,
def doOne(i: Int): Int = {i + 1; throw new RuntimeException("failed in one")}
The throw new RuntimeException("failed in one") is not within the function it is a separate line inside main flow.