/** Handle an exception. * * @param targetException the exception. * @param context the context. */ @SuppressWarnings("static-method") protected void handleInvocationTargetException(Throwable targetException, Context context) { // ignore NullPointerException, as not having to check for NPEs all the time is a convenience feature if (!(targetException instanceof NullPointerException)) { Exceptions.throwUncheckedException(targetException); } }
@Override public void accept(Exception t) { Exceptions.throwUncheckedException(t); } },
@Override public RT handle(Object[] params, Throwable e) { return Exceptions.throwUncheckedException(e); } }
public RT handle(Object[] params, Throwable e) { return Exceptions.throwUncheckedException(e); } }
/** * Invoke {@code Throwable#addSuppressed(Throwable)} reflectively if it is available. * * It is not available on JRE < 1.7 * * @since 2.8 */ public static void addSuppressed(Throwable owner, Throwable add) { try { Method method = owner.getClass().getMethod("addSuppressed", Throwable.class); method.invoke(owner, add); } catch (NoSuchMethodException e) { // ignore, will happen for JRE < 1.7 } catch (SecurityException e) { throwUncheckedException(e); } catch (IllegalAccessException e) { throwUncheckedException(e); } catch (IllegalArgumentException e) { throwUncheckedException(e); } catch (InvocationTargetException e) { throwUncheckedException(e); } }
protected String getParameterSyntax(Class<?> testClass, String methodName) { try { Method method = testClass.getMethod(methodName); ParameterSyntax annotation = method.getAnnotation(ParameterSyntax.class); if (annotation != null) return annotation.value(); } catch (SecurityException e) { Exceptions.throwUncheckedException(e); } catch (NoSuchMethodException e) { Exceptions.throwUncheckedException(e); } return null; }
public void init(Iterable<Object> actual, Class<? extends Function<Object, String>> functionClass) { items = createCollection(); try { Function<Object, String> func = functionClass.newInstance(); for (Object obj : actual) items.add(new ActualItem(func.apply(obj))); } catch (InstantiationException e) { Exceptions.throwUncheckedException(e); } catch (IllegalAccessException e) { Exceptions.throwUncheckedException(e); } } }
protected Object handleTextError(Object[] params, Throwable e) { if(e instanceof NullPointerException) { return getDefaultText(); } return Exceptions.throwUncheckedException(e); }
protected Object handleImageError(Object[] params, Throwable e) { if(e instanceof NullPointerException) { return getDefaultImage(); } return Exceptions.throwUncheckedException(e); } }
@SuppressWarnings("unchecked") protected List<URI> getURIs(FrameworkMethod method) { try { return (List<URI>) method.invokeExplosively(null); } catch (Throwable e) { Exceptions.throwUncheckedException(e); return Collections.emptyList(); } }
public static IInjectorProvider createInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { try { return injectWith.value().newInstance(); } catch (Exception e) { throwUncheckedException(e); } } return null; }
public static IInjectorProvider createInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { try { return injectWith.value().newInstance(); } catch (Exception e) { throwUncheckedException(e); } } return null; }
public boolean apply(IMarker input) { if (input.exists()) { try { if (generatorId != null && generatorId.equals(input.getAttribute(ATTR_GENERATOR))) { return true; } } catch (CoreException e) { return Exceptions.throwUncheckedException(e); } } return false; } });
protected IInjectorProvider createInjectorProvider() { IInjectorProvider injectorProvider = null; InjectWith injectWith = getTestClass().getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { try { injectorProvider = injectWith.value().newInstance(); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; }
if (!(targetException instanceof GuardException) && !(targetException instanceof NullPointerException)) Exceptions.throwUncheckedException(targetException);
public static IInjectorProvider getOrCreateInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { Class<? extends IInjectorProvider> klass = injectWith.value(); IInjectorProvider injectorProvider = injectorProviderClassCache.get(klass); if (injectorProvider == null) { try { injectorProvider = klass.newInstance(); injectorProviderClassCache.put(klass, injectorProvider); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; } return null; }
public static IInjectorProvider getOrCreateInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { Class<? extends IInjectorProvider> klass = injectWith.value(); IInjectorProvider injectorProvider = injectorProviderClassCache.get(klass); if (injectorProvider == null) { try { injectorProvider = klass.newInstance(); injectorProviderClassCache.put(klass, injectorProvider); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; } return null; }
acceptor.accept(result); } catch (Exception e) { Exceptions.throwUncheckedException(e);