Wrap everything to check for overflows
I'm still accepting input but the easiest way I know to do it as of java8+ is to make use of the Math.addExact etc methods. They're designed to throw an exception on any overflow condition. Catch that, return, donesone.
It doesn't make the code very pretty though