Suggestion for automatic wrapping of checked exceptions inside RuntimeExceptions inside closures
Behrang Saeedzadeh
behrangsa at gmail.com
Thu Apr 27 13:10:06 UTC 2017
Hi,
This has most likely been discussed before. In this yet another proposal, I
suggest adding syntax sugar to make this automated. For example, by using a
new arrow type (e.g. =>, #->, or maybe a new operator altogether: (╯°□°)╯︵
┻━┻).
So we can turn:
public class Main {
public static void main(String[] args) throws IOException {
final Path aDir = Paths.get(args[0]);
Files.list(aDir).forEach(f -> {
try {
throw new IOException();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
}
into:
public class Main {
public static void main(String[] args) throws IOException {
final Path aDir = Paths.get(args[0]);
Files.list(aDir).forEach(f (╯°□°)╯︵ ┻━┻ {
throw new IOException();
});
}
}
What do you think?
Best regards,
Behrang Saeedzadeh
More information about the discuss
mailing list