/** * If Throwable is a RuntimeException or Error, rethrow it. If not, throw a * new PalantirRuntimeException(ex) */ public static RuntimeException throwUncheckedException(Throwable ex) { throwIfInstance(ex, RuntimeException.class); throwIfInstance(ex, Error.class); throw createRuntimeException(ex); }
public T apply(F from) { try { return returnType.cast(readMethod.invoke(from)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } };
private static RuntimeException createRuntimeException(Throwable ex) { return createRuntimeException(ex.getMessage(), ex); }
public void visit(Class<?> klass){ if (didBind[0]) { return; } WiringHarness<Bound, Field> wiringHarness = wiringHarnesses.get(klass); if (wiringHarness == null) { return; } try { bindings.addAll(wiringHarness.wire(bound, context, field)); didBind[0] = true; } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } });
public Collection<Binding> wire(BindingContext context) { List<Field> boundFields = context.getAnnotatedFields(BoundLocation.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { BoundLocation bound = field.getAnnotation(BoundLocation.class); try { bindings.addAll(wire(bound, context, field)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } return bindings; }
public Collection<Binding> wire(BindingContext context) { List<Field> boundFields = context.getAnnotatedFields(BoundSelection.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { BoundSelection bound = field.getAnnotation(BoundSelection.class); try { bindings.addAll(wire(bound, context, field)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } return bindings; }
public Collection<Binding> wire(BindingContext context) { List<Field> boundFields = context.getAnnotatedFields(BoundExtent.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { BoundExtent bound = field.getAnnotation(BoundExtent.class); try { bindings.addAll(wire(bound, context, field)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } return bindings; }
throw Throwables.throwUncheckedException(e);