You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The IOException type is rather awkward to use, especially if you look at it from a coroutine point of view. If, for example, I'm only interested in the file not being found and I'm fine with other exceptions being bubbled up I'd have to write something like this.
try {
FileSystem.info(path).modificationTime;
// do other stuff
} catch (exn:IOException) {
if (exn.type.match(FileNotFound)) {
returnfalse;
}
// rethrow exceptions we're not handling...throwexn;
}
Usually I'm all for reducing inheritance but with the built in type checking of catches, having exception sub classes for each exception type makes for nicer code and less likely to accidentally swallow errors.
try {
FileSystem.info(path).modificationTime;
// do other stuff
} catch (_:FileNotFoundException) {
returnfalse;
}
The text was updated successfully, but these errors were encountered:
The IOException type is rather awkward to use, especially if you look at it from a coroutine point of view. If, for example, I'm only interested in the file not being found and I'm fine with other exceptions being bubbled up I'd have to write something like this.
Usually I'm all for reducing inheritance but with the built in type checking of catches, having exception sub classes for each exception type makes for nicer code and less likely to accidentally swallow errors.
The text was updated successfully, but these errors were encountered: