i reviewing code last time searching exceptions when stopped on line of code:
var list: array[string] = source.fromfile(this.path).getlines.toarray
i searched in documentation on scala-lang seems none of methods of line throws kind of ioexception
... how possible?
edit:
try { var list: array[string] = source.fromfile("").getlines.toarray } catch { case ex:exception => println(ex.getmessage) }
does not print anything, why?
checked exceptions enforced javac, jvm don't know them. , contrary java, scala doesn't care checked exceptions.
look @ source instance, won't notice code dealing exceptions. impossible in old java, require try
/catch
s or throws
clauses.
despite that, scala library author may still want make sure java users check these exceptions, there @throws annotation, let declare method may throw exception throws
java clause. make sure keep in mind @throws
java consumption.
you may want take @ scala.util.control.exception. contains sorts of goodies dealing exceptions.
Comments
Post a Comment