called when self.runtest() raises an exception.
182614
def repr_failure(self, excinfo):
        
        exc = excinfo.value
        cc = self.colors
        if isinstance(exc, NbCellError):
            msg_items = [
                cc.FAIL + "Notebook cell execution failed" + cc.ENDC]
            formatstring = (
                cc.OKBLUE + "Cell %d: %s\n\n" +
                "Input:\n" + cc.ENDC + "%s\n")
            msg_items.append(formatstring % (
                exc.cell_num,
                str(exc),
                exc.source
            ))
            if exc.inner_traceback:
                msg_items.append((
                    cc.OKBLUE + "Traceback:" + cc.ENDC + "\n%s\n") %
                    exc.inner_traceback)
            return "\n".join(msg_items)
        else:
            return "pytest plugin exception: %s" % str(exc)
1108767
def set_exception(self, exception):
        '''
        
        '''
        if hasattr(self, '_result'):
            raise ValueError('Cannot set the result twice')
        self._result = None
        self._exception = exception
        self._scheduler.emergesend(FutureEvent(self, exception = exception))
48256
protected void doStart() throws Exception
    {
        if (isStarted())
            return;

        // save context classloader
        Thread thread= Thread.currentThread();
        ClassLoader lastContextLoader= thread.getContextClassLoader();

        MultiException mex= null;
        try
        {
            // Find the webapp
            resolveWebApp();

            // Get the handler
            getServletHandler();
          
            _configurations=loadConfigurations();
            
            // initialize the classloader            
            configureClassPath();
            initClassLoader(true);
            thread.setContextClassLoader(getClassLoader());
            initialize();
            
            // Do the default configuration
            configureDefaults();

            // Set classpath for Jasper.
            Map.Entry entry= _webAppHandler.getHolderEntry("test.jsp");
            if (entry != null)
            {
                ServletHolder jspHolder= (ServletHolder)entry.getValue();
                if (jspHolder != null && jspHolder.getInitParameter("classpath") == null)
                {
                    String fileClassPath= getFileClassPath();
                    jspHolder.setInitParameter("classpath", fileClassPath);
                    if (log.isDebugEnabled())
                        log.debug("Set classpath=" + fileClassPath + " for " + jspHolder);
                }
            }
            
            // configure webapp
            configureWebApp();

            // If we have servlets, don't init them yet
            _webAppHandler.setAutoInitializeServlets(false);

            // Start handlers
            super.doStart();

            mex= new MultiException();
            // Context listeners
            if (_contextListeners != null && _webAppHandler != null)
            {
                ServletContextEvent event= new ServletContextEvent(getServletContext());
                for (int i= 0; i < LazyList.size(_contextListeners); i++)
                {
                    try
                    {
                        ((ServletContextListener)LazyList.get(_contextListeners, i)).contextInitialized(event);
                    }
                    catch (Exception ex)
                    {
                        mex.add(ex);
                    }
                }
            }

            // OK to Initialize servlets now
            if (_webAppHandler != null && _webAppHandler.isStarted())
            {
                try
                {
                    _webAppHandler.initializeServlets();
                }
                catch (Exception ex)
                {
                    mex.add(ex);
                }
            }
        }
        catch (Exception e)
        {
            log.warn("Configuration error on " + _war, e);
            throw e;
        }
        finally
        {
            thread.setContextClassLoader(lastContextLoader);
        }

        if (mex != null)
            mex.ifExceptionThrow();
    }
380946
public void start() throws Exception
    {
        Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");

        client.createContainers(queuePath);

        getInitialQueues();
        leaderLatch.start();

        service.submit
        (
            new Callable<Void>()
            {
                @Override
                public Void call() throws Exception
                {
                    while ( state.get() == State.STARTED )
                    {
                        try
                        {
                            Thread.sleep(policies.getThresholdCheckMs());
                            checkThreshold();
                        }
                        catch ( InterruptedException e )
                        {
                            // swallow the interrupt as it's only possible from either a background
                            // operation and, thus, doesn't apply to this loop or the instance
                            // is being closed in which case the while test will get it
                        }
                    }
                    return null;
                }
            }
        );
    }
1343962
def exceptionCaught(self, exc=None, **kwargs):
        ''
        if isinstance(exc, ExpectedException):  # already reported, don't log
            return
        self.lastErrors.append(stacktrace())
        if kwargs.get('status', True):
            status(self.lastErrors[-1][-1], priority=2)  # last line of latest error
        if options.debug:
            raise
1039845
public static void asUnchecked(Throwable t, Class<? extends RuntimeException> checkedExceptionWrapper) {
        if (t instanceof AssertionError) {
            throw (AssertionError) t;
        } else if (t instanceof RuntimeException) {
            throw (RuntimeException) t;
        } else {
            RuntimeException exception;
            try {
                exception = checkedExceptionWrapper.getConstructor(Throwable.class).newInstance(t);
            } catch (Exception e) {
                throw new RuntimeException(t);
            }
            throw exception;
        }
    }
209785
def run(self):
        """"""
        try:
            if self._target:
                return_value = self._target(*self._args, **self._kwargs)
                if return_value is not None:
                    self._exception = OrphanedReturn(self, return_value)
        except BaseException as err:
            self._exception = err
        finally:
            # Avoid a refcycle if the thread is running a function with
            # an argument that has a member that points to the thread.
            del self._target, self._args, self._kwargs
567536
def run(self):
        '''
            
        '''

        # Try to silence default exception printing.
        self.otherThread._Thread__stderr = self._stderr
        if hasattr(self.otherThread, '_Thread__stop'):
            # If py2, call this first to start thread termination cleanly.
            #   Python3 does not need such ( nor does it provide.. )
            self.otherThread._Thread__stop()
        while self.otherThread.isAlive():
            # We loop raising exception incase it's caught hopefully this breaks us far out.
            ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.otherThread.ident), ctypes.py_object(self.exception))
            self.otherThread.join(self.repeatEvery)

        try:
            self._stderr.close()
        except:
            pass
213787
public void run() throws Exception {
        // Send the initial command:
        client.sendRequest(cmd);

        long endTime = System.currentTimeMillis() + spec.getMaxDuration();

        // Wait until the 'after' time
        Thread.sleep(spec.getAfter());

        int numAttempts = 0;
        long now = System.currentTimeMillis();

        while (now < endTime) {
            client.sendRequest(cmd);
            now = System.currentTimeMillis();

            numAttempts ++;

            // See how to retry:
            long sleepTime = 0;
            if (spec.isConstant()) {
                sleepTime = spec.getInterval();
            } else if (spec.isLinear()) {
                sleepTime = spec.getInterval() * numAttempts;
            } else if (spec.isExponential()) {
                sleepTime = (long) Math.pow(spec.getInterval(), numAttempts);
            }

            if (spec.getCeil() > 0) {
                sleepTime = Math.min(spec.getCeil(), sleepTime);
            }

            if (now + sleepTime > endTime) {
                break;
            } else {
                accuSleep(sleepTime);
                now = System.currentTimeMillis();
            }
        }
    }
380757
def on_assert(self, node):    # ('test', 'msg')
        """"""
        if not self.run(node.test):
            self.raise_exception(node, exc=AssertionError, msg=node.msg)
        return True
1241803
public void setException(Throwable t) {
    if (err == null) {
      t.printStackTrace();
    } else {
      err.emit(t);
    }
  }
1190667
def raise_on_failure(mainfunc):
    """"""
    try:
        errors = mainfunc()
        if errors:
            exit(errors)
    except CalledProcessError as error:
        exit(error.returncode)
    except SystemExit as error:
        if error.code:
            raise
    except KeyboardInterrupt:  # I don't plan to test-cover this.  :pragma:nocover:
        exit(1)
125936
public static RuntimeException codeBug()
        throws RuntimeException
    {
        RuntimeException ex = new IllegalStateException("FAILED ASSERTION");
        // Print stack trace ASAP
        ex.printStackTrace(System.err);
        throw ex;
    }
289503
def on_exception(self, exception):
        """"""
        logger.error('Exception from stream!', exc_info=True)
        self.streaming_exception = exception
612599
public static RuntimeException rethrow(RequestExecutionException e) throws UnavailableException, TimedOutException
    {
        if (e instanceof RequestTimeoutException)
            throw toThrift((RequestTimeoutException)e);
        else
            throw new UnavailableException();
    }
820019
public void run(String... args) throws Exception {
        ClassLoader old = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader( classLoader  );

        try {
            doRun( args);
        } catch (Exception e) {
            monitor.exceptionOccured( e );
        }

        Thread.currentThread().setContextClassLoader( old );
    }
753946
public void waitUntilNoMoreException(final Runnable runnable, final List<Class<? extends Exception>> expectedExceptions) {

        final List<RuntimeException> actualExceptions = new ArrayList<>();
        int tries = 0;
        while (tries < maxTries) {
            try {
                runnable.run();
                return;
            } catch (final RuntimeException ex) {
                if (!Utils4J.expectedException(ex, expectedExceptions) && !Utils4J.expectedCause(ex, expectedExceptions)) {
                    throw ex;
                }
                actualExceptions.add(ex);
                tries++;
                Utils4J.sleep(sleepMillis);
            }
        }
        throw new IllegalStateException("Waited too long for execution without exception. Expected exceptions: " + expectedExceptions
                + ", Actual exceptions: " + actualExceptions);

    }