A variant of assertArg(Consumer) for lambdas declaring checked exceptions.
960610
@Incubating
    public static <T> T assertArgThrowing(ThrowingConsumer<T> throwingConsumer) {
        argThat(throwingConsumer.uncheck());
        return handyReturnValues.returnForConsumerLambdaChecked(throwingConsumer);
    }
1136722
public static <T, E extends Exception> Consumer<T> rethrowConsumer(ConsumerWithExceptions<T, E> consumer) throws E {
        return t -> {
            try {
                consumer.accept(t);
            } catch (Exception exception) {
                throwAsUnchecked(exception);
            }
        };
    }
45434
public static <T> ObjIntConsumer<T> objIntConsumer(CheckedObjIntConsumer<T> consumer) {
        return objIntConsumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
    }
1109597
private static void assertConsumer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {

        Set<Resource<ResourceType>> producedTypes = unit.getOutputs();

        for (Resource<ResourceType> resource : producedTypes) {
            boolean match = false;

            for(QName id : behaviours.keySet())
            {
                for (Behaviour behaviour : behaviours.get(id)) {

                    if (behaviour.doesConsume(resource)) {
                        match = true;
                        break;
                    }
                }
            }
            if (!match)
                err.add(unit.getId(), "Missing consumer for <<" + resource + ">>");
        }

    }
856388
public static void checkArgument(boolean b, String msg, Object arg1) {
        if (!b) {
            throwEx(msg, arg1);
        }
    }
908180
def exception_catcher(fn):
    
    exceptions = Queue.Queue()

    @wraps(fn)
    def wrapped(*args, **kwargs):
        try:
            ret = fn(*args, **kwargs)
        except Exception:
            exceptions.put(sys.exc_info())
            raise
        return ret

    def check():
        try:
            item = exceptions.get(block=False)
            klass, value, tb = item
            raise klass, value, tb
        except Queue.Empty:
            pass

    setattr(wrapped, 'check', check)
    return wrapped
1099940
def find_lambda_condition(decorator_inspection: DecoratorInspection) -> Optional[ConditionLambdaInspection]:
    
    call_node = decorator_inspection.node

    lambda_node = None  # type: Optional[ast.Lambda]

    if len(call_node.args) > 0:
        assert isinstance(call_node.args[0], ast.Lambda), \
            ("Expected the first argument to the decorator to be a condition as lambda AST node, "
             "but got: {}").format(type(call_node.args[0]))

        lambda_node = call_node.args[0]

    elif len(call_node.keywords) > 0:
        for keyword in call_node.keywords:
            if keyword.arg == "condition":
                assert isinstance(keyword.value, ast.Lambda), \
                    "Expected lambda node as value of the 'condition' argument to the decorator."

                lambda_node = keyword.value
                break

        assert lambda_node is not None, "Expected to find a keyword AST node with 'condition' arg, but found none"
    else:
        raise AssertionError(
            "Expected a call AST node of a decorator to have either args or keywords, but got: {}".format(
                ast.dump(call_node)))

    return ConditionLambdaInspection(atok=decorator_inspection.atok, node=lambda_node)
1031644
public Violation checkInstantiation(
      Collection<TypeVariableSymbol> typeParameters, Collection<Type> typeArguments) {
    return Streams.zip(
            typeParameters.stream(),
            typeArguments.stream(),
            (sym, type) -> {
              if (!hasThreadSafeTypeParameterAnnotation(sym)) {
                return Violation.absent();
              }
              Violation info =
                  isThreadSafeType(
                      /* allowContainerTypeParameters= */ true,
                      /* containerTypeParameters= */ ImmutableSet.of(),
                      type);
              if (!info.isPresent()) {
                return Violation.absent();
              }
              return info.plus(
                  String.format(
                      "instantiation of '%s' is %s", sym, purpose.mutableOrNotThreadSafe()));
            })
        .filter(Violation::isPresent)
        .findFirst()
        .orElse(Violation.absent());
  }
975478
protected static void assertion(boolean b, String msg)
  {
  	if(!b)
  	{
  		throw new RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, new Object[]{msg}));
  		// "Programmer's assertion in RundundentExprEliminator: "+msg);
  	}
  }
386796
public static void assertTrueOrInvalidMethodSignException(boolean expression, SQLiteModelMethod method,
			String messageFormat, Object... args) {
		if (!expression)
			throw (new InvalidMethodSignException(method, String.format(messageFormat, args)));
	}
1140380
public CTX to(@Nonnull java.util.function.Consumer<RS> assertions) {
        normalCheck(description, caseDescription, preconditioner, assertFunction, assertPreConsumer, assertions);
        return context.self();
    }
810936
public <T> void assertThat(T actual, org.hamcrest.Matcher<? super T> matcher) {
    try {
      org.hamcrest.MatcherAssert.assertThat(actual, matcher);
    } catch (AssertionError e) {
      fail(e);
    }
  }
674897
public CTX withException(@Nonnull Consumer<AbstractThrowableAssert<?, ? extends Throwable>> assertions) {
        exceptionCheck(description, caseDescription, preconditioner, assertFunction, assertions);
        return context.self();
    }
904119
def __assert_param_consistency(args, argx_list_):
    
    if util_arg.NO_ASSERTS:
        return
    if len(argx_list_) == 0:
        return True
    argx_flags = [util_iter.isiterable(args[argx]) for argx in argx_list_]
    try:
        assert all([argx_flags[0] == flag for flag in argx_flags]), (
            'invalid mixing of iterable and scalar inputs')
    except AssertionError as ex:
        print('!!! ASSERTION ERROR IN UTIL_DECOR !!!')
        for argx in argx_list_:
            print('[util_decor] args[%d] = %r' % (argx, args[argx]))
        raise ex
90963
public static <T> T assertNotNull(T object, ExceptionType exceptionType, String message, Object... args) {
        if (object == null) {
            if (exceptionType == null) {
                exceptionType = ExceptionType.ILLEGAL_ARGUMENT;
            }

            throw exceptionType.newInstance(getMessage(message, args,
                                                       "[Assertion failed] - the argument is required; it must not be null"));
        }

        return object;
    }
1203606
function assertExpectations({assertion, actual, expectations, message, prefix, stack}) {
	if (!isError(actual)) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			values: [formatWithLabel(`${prefix} exception that is not an error:`, actual)]
		});
	}

	const actualStack = actual.stack;

	if (hasOwnProperty(expectations, 'is') && actual !== expectations.is) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected to be strictly equal to:', expectations.is)
			]
		});
	}

	if (expectations.instanceOf && !(actual instanceof expectations.instanceOf)) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected instance of:', expectations.instanceOf)
			]
		});
	}

	if (typeof expectations.name === 'string' && actual.name !== expectations.name) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected name to equal:', expectations.name)
			]
		});
	}

	if (typeof expectations.message === 'string' && actual.message !== expectations.message) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected message to equal:', expectations.message)
			]
		});
	}

	if (expectations.message instanceof RegExp && !expectations.message.test(actual.message)) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected message to match:', expectations.message)
			]
		});
	}

	if (typeof expectations.code !== 'undefined' && actual.code !== expectations.code) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected code to equal:', expectations.code)
			]
		});
	}
}
869305
public static <T> Comparator<T> comparator(CheckedComparator<T> comparator, Consumer<Throwable> handler) {
        return (t1, t2) -> {
            try {
                return comparator.compare(t1, t2);
            }
            catch (Throwable e) {
                handler.accept(e);

                throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
            }
        };
    }