List of usage examples for java.lang Error addSuppressed
public final synchronized void addSuppressed(Throwable exception)
From source file:org.nuxeo.runtime.test.runner.ConditionalIgnoreRule.java
protected void injectCondition(Class<?> type, Method method, Object target, Condition condition) throws SecurityException, Error { Error errors = new Error("Cannot inject condition parameters in " + condition.getClass()); for (Field eachField : condition.getClass().getDeclaredFields()) { if (!eachField.isAnnotationPresent(Inject.class)) { continue; }// ww w . j a va 2 s .c om Object eachValue = null; if (eachField.isAnnotationPresent(Named.class)) { String name = eachField.getAnnotation(Named.class).value(); if ("type".equals(name)) { eachValue = type; } else if ("target".equals(name)) { eachValue = target; } else if ("method".equals(name)) { eachValue = method; } } else { Class<?> eachType = eachField.getType(); if (eachType.equals(Class.class)) { eachValue = type; } else if (eachType.equals(Object.class)) { eachValue = target; } else if (eachType.equals(Method.class)) { eachValue = method; } } if (eachValue == null) { continue; } eachField.setAccessible(true); try { eachField.set(condition, eachValue); } catch (IllegalArgumentException | IllegalAccessException cause) { errors.addSuppressed(new Error("Cannot inject " + eachField.getName(), cause)); } } if (errors.getSuppressed().length > 0) { throw errors; } runner.getInjector().injectMembers(condition); }