0

I'm using Netbeans 12.4 and for some reason I'm getting the following error despite me declaring the exception at compile-time:

unreported exception DoesNotExistsException must be caught or declared to be thrown

@Override
    public void deleteB(Long bId) throws DoesNotExistsException {
 
    B b = em.find(B.class, bId);
    em.remove(b);
    
    A mandatoryA = new A();
    mandatoryA.getBs().stream().map(bInSet -> bInSet.getA().orElseThrow(() -> new DoesNotExistsException("Mandatory A does not exist!"))) 
            .filter(a -> a.getCurrentB().equals(b))
            .forEach(a -> a.setCurrentB(null));

}

Edit: DoesNotExistsException simply extends Exception

Leon
  • 336
  • 3
  • 13

0 Answers0