4 ms·
> So you call say 3 methods, and at the end you have a "file not found" error... which call resulted in that failure? The first exception hit pops out the othe
by eropple 12y ago
> So you call say 3 methods, and at the end you have a "file not found" error... which call resulted in that failure?
The first exception hit pops out the other side and you pattern-match against it. So, the one that did file access and returned a FileNotFoundException. If you have multiple pieces of code that can return FileNotFoundExceptions, you can pass a message in the exception, just like any other Java exception. You can often be more type-specific, too. Bear in mind that defining a new exception in Scala is a one-liner, and you can encapsulate your FileNotFoundException in a RetrievalFailedException very easily and cleanly.
Your method is not more robust, I assure you--it's just verbose and both typo- and thinko-prone.