0

in java, if there is a exception in code and you are untreated or not throwing out, compiling will be failed. But in scala, it will be compiling successfully.

So how to know whether there is a exception that untreated in scala code?

Guo
  • 1,761
  • 2
  • 22
  • 45
  • 1
    The [prevalent opinion](http://stackoverflow.com/q/613954/2032064) on checked exceptions is that they are not a good idea so you shouldn't miss them much. – Mifeet May 12 '16 at 09:32

1 Answers1

0

The situation is the same as for unchecked exceptions (RuntimeExceptions) in Java: the compiler won't complain about them not being handled.

You have to rely on the source code and documentation to see what exceptions you might get from a piece of code.

In Scala, you should probably avoid exceptions in favour of Try monads when you expect the caller to deal with them (i.e. when you would use a checked exception in Java).

Thilo
  • 257,207
  • 101
  • 511
  • 656