Creates a matcher for a {@link Throwable} that matches when the provided {@code Throwable} instance is the same or a subtype
of the given class and has the same message in the error message or the message is contained in the error message
427567
public static Matcher<Throwable> exceptionWithMessage(Class<? extends Throwable> type, String expectedMessage) {
        return new ExpectedException(type, expectedMessage);
    }
1342959
public static <T> DecomposableMatchBuilder1<T, T> caseThat(org.hamcrest.Matcher<T> matcher) {
    @SuppressWarnings("unchecked")
    List<Matcher<Object>> matchers = Lists.of((Matcher<Object>) HamcrestMatcher.of(matcher));

    return new DecomposableMatchBuilder1<>(matchers, 0, new IdentityFieldExtractor<>());
  }
923360
public static Matcher<Class<?>> subclassOf(final Class<?> klazz) {
    return new Matcher<Class<?>>() {

      @Override
      protected boolean matchesSafely(Class<?> t) {
        return klazz.isAssignableFrom(t);
      }

      @Override
      public String toString() {
        return "a subtype of " + klazz;
      }
    };
  }
1357167
public static <T extends Tree> Matcher<T> isInstance(final java.lang.Class<?> klass) {
    return new Matcher<T>() {
      @Override
      public boolean matches(T t, VisitorState state) {
        return klass.isInstance(t);
      }
    };
  }
708912
@Factory
    public static <T extends Throwable> Matcher<T> isThrowable(Class<?> type) {
        final Matcher<T> typeMatcher = instanceOf(type);
        return new IsThrowable<>(typeMatcher);
    }
822705
public static <T extends Throwable> Matcher<T> isThrowable(Class<?> type) {
        return IsThrowable.isThrowable(type);
    }
998094
public void sendException(Throwable throwable) {
        EventBuilder eventBuilder = new EventBuilder().withMessage(throwable.getMessage())
            .withLevel(Event.Level.ERROR)
            .withSentryInterface(new ExceptionInterface(throwable));
        sendEvent(eventBuilder);
    }
1156323
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasType(ElementMatcher<? super TypeDescription> matcher) {
        return hasGenericType(erasure(matcher));
    }
535082
def match(match_expr, exc_type, exc_value, exc_traceback):
    
    # Emulate standard behavior when match_expr is an exception subclass.
    if isinstance(match_expr, type) and issubclass(match_expr, BaseException):
        return issubclass(exc_type, match_expr)

    # Match on type and args when match_expr is an exception instance.
    return (
        issubclass(exc_type, type(match_expr))
        and
        match_expr.args == exc_value.args
    )
583672
@Factory
    public static <T extends Throwable> Matcher<T> withMessage(String message) {
        return withMessage(is(message));
    }
527113
public <U extends T> OngoingMatchingC0<T, U> when(
      DecomposableMatchBuilder0<U> decomposableMatchBuilder) {
    return new OngoingMatchingC0<>(this, decomposableMatchBuilder.build());
  }
994591
public static Throwable stripException(Throwable throwableToStrip, Class<? extends Throwable> typeToStrip) {
		while (typeToStrip.isAssignableFrom(throwableToStrip.getClass()) && throwableToStrip.getCause() != null) {
			throwableToStrip = throwableToStrip.getCause();
		}

		return throwableToStrip;
	}
603754
public static Matcher<Object> hasSingleFailureContaining(final String string) {
        return new BaseMatcher<Object>() {
            public boolean matches(Object item) {
                return item.toString().contains(string) && failureCountIs(1).matches(item);
            }

            public void describeTo(Description description) {
                description.appendText("has single failure containing " + string);
            }
        };
    }
25221
@SuppressWarnings("unchecked")
	public static <T extends Throwable> T wrap(Throwable throwable, Class<T> wrapThrowable) {
		if (wrapThrowable.isInstance(throwable)) {
			return (T) throwable;
		}
		return ReflectUtil.newInstance(wrapThrowable, throwable);
	}
633950
public static <T extends Throwable> T findException(Class<T> exceptionTypeToFind, Throwable t) {

    Throwable cause = t;

    while (cause != null)
    {
      if( exceptionTypeToFind.isAssignableFrom( cause.getClass() ) )
      {
        //noinspection unchecked
        return (T)cause;
      }
      if( cause == cause.getCause() )
      {
        return null;
      }
      cause = cause.getCause();
    }

    return null;
  }
600387
public static MultiMatcher<MethodTree, VariableTree> methodHasParameters(
      MatchType matchType, Matcher<VariableTree> parameterMatcher) {
    return new MethodHasParameters(matchType, parameterMatcher);
  }
425728
public static RuntimeException wrap(Throwable throwable) {
        RuntimeException result;
        if (throwable instanceof RuntimeException) {
            result = (RuntimeException) throwable;
        } else {
            result = new RuntimeException(throwable.getClass().getSimpleName(), throwable);
        }
        return result;
    }