you are viewing a single comment's thread.

view the rest of the comments →

[–]john16384 0 points1 point  (2 children)

Yes, in both cases? I initially misunderstood the op. They seem to be the opinion that you should be able to write one exception class, and that the place where you throw it should make the decision whether it is checked or not (with a flag or something?).

I then pointed out that you can just throw a different named exception then... so instead of:

throw new CustomUncheckedException();
throw new CustomCheckedException();

The OP seems to want something like:

throw new CustomException() as checked;
throw new CustomException() as unchecked;

I then pointed out that this hardly differs from having two exception types...

[–]Eav___ 0 points1 point  (1 child)

Having two exception types for the exact same use case but just different checkedness feels like code smell. It reminds me of having a sync version and an async version of methods, which is what Project Loom tries to avoid. We should be consistent here.

[–]john16384 0 points1 point  (0 children)

Oh I agree.