On Fri, 28 Oct 2022 22:23:13 GMT, Jonathan Gibbons <[email protected]> wrote:

>> I don't (yet?) see why that language design issue arises here.   It looks 
>> like you're doing a multi-catch of a series of 4 subtypes of `Failure`, and 
>> an "other".  I don't see where any exception type parameter comes in.
>
> Ah OK, there's one hidden in the signature of the `trySearch` method. Is that 
> one important?

trySearch throws Failure, because it cannot throw a union consisting of these 
three exceptions using just a single exception type parameter:

* Failure.UnsupportedTypeParameter
* Failure.ExceptionTypeNotFound
* Failure.NotExceptionType

So I make a general "Failure" mixture, from which I'll later refine individual 
constituents. I think we can do this, but that's it:

        try {
            result = utils.docFinder().trySearch(holder, criterion);
        } catch (Failure.NotExceptionType
                 | Failure.ExceptionTypeNotFound
                 | Failure.UnsupportedTypeParameter x) {
            throw x;
        } catch (Failure f) {
            throw newAssertionError(f);
        }

Maybe my comment was misplaced (the comment is about `Criterion`, not 
`trySearch`)? I can perhaps remove it altogether if it doesn't bring much value.

-------------

PR: https://git.openjdk.org/jdk/pull/10746

Reply via email to