private MultiException addMultiException(MultiException exception, Exception e) { if(exception == null){ exception = new MultiException(); } exception.add(e); return exception; }
private MultiException addMultiException(MultiException exception, Exception e) { if(exception == null){ exception = new MultiException(); } exception.add(e); return exception; }
@Override public void destroy() { // Prepare for configuration MultiException mx=new MultiException(); if (_configurations!=null) { for (int i=_configurations.size();i-->0;) { try { _configurations.get(i).destroy(this); } catch(Exception e) { mx.add(e); } } } _configurations.clear(); super.destroy(); mx.ifExceptionThrowRuntime(); }
/** Throw a multiexception. * If this multi exception is empty then no action is taken. If it * contains a any exceptions then this * multi exception is thrown. * @throws MultiException the multiexception if there are nested exception */ public void ifExceptionThrowMulti() throws MultiException { if(nested == null) return; if (nested.size()>0) { throw new MultiException(nested); } }
/** Throw a multiexception. * If this multi exception is empty then no action is taken. If it * contains a single exception that is thrown, otherwise the this * multi exception is thrown. * @exception Exception the Error or Exception if nested is 1, or the MultiException itself if nested is more than 1. */ public void ifExceptionThrow() throws Exception { if(nested == null) return; switch (nested.size()) { case 0: break; case 1: Throwable th=nested.get(0); if (th instanceof Error) throw (Error)th; if (th instanceof Exception) throw (Exception)th; default: throw new MultiException(nested); } }
throw new RuntimeException(th); default: throw new RuntimeException(new MultiException(nested));
/** Throw an Exception, potentially with suppress. * If this multi exception is empty then no action is taken. If the first * exception added is an Error or Exception, then it is throw with * any additional exceptions added as suppressed. Otherwise a MultiException * is thrown, with all exceptions added as suppressed. * @exception Exception the Error or Exception if at least one is added. */ public void ifExceptionThrowSuppressed() throws Exception { if(nested == null || nested.size()==0) return; Throwable th=nested.get(0); if (!Error.class.isInstance(th) && !Exception.class.isInstance(th)) th = new MultiException(Collections.emptyList()); for (Throwable s : nested) { if (s!=th) th.addSuppressed(s); } if (Error.class.isInstance(th)) throw (Error)th; throw (Exception)th; }
/** * Stops the managed lifecycle beans in the reverse order they were added. */ @Override protected void doStop() throws Exception { _doStarted = false; super.doStop(); List<Bean> reverse = new ArrayList<>(_beans); Collections.reverse(reverse); MultiException mex = new MultiException(); for (Bean b : reverse) { if (b._managed==Managed.MANAGED && b._bean instanceof LifeCycle) { LifeCycle l = (LifeCycle)b._bean; try { stop(l); } catch (Throwable th) { mex.add(th); } } } mex.ifExceptionThrow(); }
final MultiException me = new MultiException(); try (Stream<Path> stream = Files.list( dir))
/** * Delete any tmp storage for parts, and clear out the parts list. */ public void deleteParts () { if(!_parsed) return; Collection<Part> parts = getParsedParts(); MultiException err = new MultiException(); for (Part p:parts) { try { ((MultiPartInputStreamParser.MultiPart)p).cleanUp(); } catch(Exception e) { err.add(e); } } _parts.clear(); err.ifExceptionThrowRuntime(); }
/** Throw a multiexception. * If this multi exception is empty then no action is taken. If it * contains a any exceptions then this * multi exception is thrown. * @throws MultiException the multiexception if there are nested exception */ public void ifExceptionThrowMulti() throws MultiException { if(nested == null) return; if (nested.size()>0) { throw new MultiException(nested); } }
private MultiException addMultiException(MultiException exception, Exception e) { if(exception == null){ exception = new MultiException(); } exception.add(e); return exception; }
private MultiException addMultiException(MultiException exception, Exception e) { if(exception == null){ exception = new MultiException(); } exception.add(e); return exception; }
private MultiException addMultiException(MultiException exception, Exception e) { MultiException newException = exception; if (newException == null) { newException = new MultiException(); } newException.add(e); return newException; }
private MultiException addMultiException(MultiException exception, Exception e) { if(exception == null){ exception = new MultiException(); } exception.add(e); return exception; }
@Override protected void doStop() throws Exception { MultiException mex=new MultiException(); try { super.doStop(); } catch(Throwable e){mex.add(e);} if (_handlers!=null) { for (int i=_handlers.length;i-->0;) try{_handlers[i].stop();}catch(Throwable e){mex.add(e);} } mex.ifExceptionThrow(); }
@Override protected void doStop() throws Exception { MultiException mex=new MultiException(); try { super.doStop(); } catch(Throwable e){mex.add(e);} if (_handlers!=null) { for (int i=_handlers.length;i-->0;) try{_handlers[i].stop();}catch(Throwable e){mex.add(e);} } mex.ifExceptionThrow(); }
@Override protected void doStop() throws Exception { MultiException mex=new MultiException(); try { super.doStop(); } catch(Throwable e){mex.add(e);} if (_handlers!=null) { for (int i=_handlers.length;i-->0;) try{_handlers[i].stop();}catch(Throwable e){mex.add(e);} } mex.ifExceptionThrow(); }
@Override protected void doStop() throws Exception { MultiException mex=new MultiException(); try { super.doStop(); } catch(Throwable e){mex.add(e);} if (_handlers!=null) { for (int i=_handlers.length;i-->0;) try{_handlers[i].stop();}catch(Throwable e){mex.add(e);} } mex.ifExceptionThrow(); }
@Override protected void doStop() throws Exception { MultiException mex=new MultiException(); try { super.doStop(); } catch(Throwable e){mex.add(e);} if (_handlers!=null) { for (int i=_handlers.length;i-->0;) try{_handlers[i].stop();}catch(Throwable e){mex.add(e);} } mex.ifExceptionThrow(); }