001package org.reactivestreams.tck.support;
002
003
004/**
005 * Copy of scala.control.util.NonFatal in order to not depend on scala-library
006 */
007public class NonFatal {
008  private NonFatal() {
009    // no instances, please.
010  }
011
012  /**
013   * Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal
014   *
015   * @param t throwable to be matched for fatal-ness
016   * @return true if is a non-fatal throwable, false otherwise
017   */
018  public static boolean isNonFatal(Throwable t) {
019    if (t instanceof StackOverflowError) {
020      // StackOverflowError ok even though it is a VirtualMachineError
021      return true;
022    } else if (t instanceof VirtualMachineError ||
023        t instanceof ThreadDeath ||
024        t instanceof InterruptedException ||
025        t instanceof LinkageError) {
026      // VirtualMachineError includes OutOfMemoryError and other fatal errors
027      return false;
028    } else {
029      return true;
030    }
031  }
032}