@param EnvelopeInterface $envelope
@param \Exception        $exception

@throws ProcessExhaustedException

@return bool
188244
protected function retryMessage(EnvelopeInterface $envelope, \Exception $exception = null)
    {
        $attempt = $this->getAttemptValue($envelope);
        if ($attempt >= $this->maxAttempts) {
            throw new ProcessExhaustedException(sprintf('Exhausted after failing %d attempt(s)', $attempt));
        }

        $this->logger->debug(sprintf('Requeueing message (%d attempts left)', $this->maxAttempts - $attempt));

        return $this->strategy->retry($envelope, ++$attempt, $exception);
    }
835076
protected function convertExceptionToServiceException(Exception $e): ServiceException
    {
        $exception = get_class($e);
        $conversion = $this->container['config']->get('exception.conversion', []);

        if (isset($conversion[$exception])) {
            return new $conversion[$exception]($e->getMessage(), $e->getCode(), $e);
        } /*else if (in_array($exception, $conversion, true)) {
            return new ServiceException($e->getMessage(), 400, $e);
        }*/ else {
            $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 400;

            return new ServiceException($e->getMessage(), $statusCode, $e);
        }
    }
1265818
protected function processTwig(Exception $exception)
    {
        // Must be a Twig related exception
        if (!$exception instanceof Twig_Error) {
            return false;
        }

        $this->message = $exception->getRawMessage();
        $this->line = $exception->getTemplateLine();

        // Find where the twig markup section begins
        $offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
        $this->line += $offsetArray['markup'];

        // Account for line 0
        $this->line--;

        return true;
    }
494001
protected function consumeCallback(Message $message, Envelope $envelope = null) : bool
    {
        if ($message->getMessage()) {
            $this->count++;
        }

        if ($message->getMessage()) {
            return $this->consume($message, $envelope);
        }

        if ($this->mustQuit()) {
            $message->quit(true);
        }

        return true;
    }
1226011
public function isRetryableException(\Exception $e, $query = null)
    {
        if (null === $query || $this->isUpdateQuery($query)) {
            return $this->_driver->isGoneAwayInUpdateException($e);
        }

        return $this->_driver->isGoneAwayException($e);
    }
681927
private function handleInternalException(\Exception $ex)
    {
        $response = null;

        if ($ex instanceof ResponseAwareExceptionInterface) {
            $response = $ex->getResponse();
        }

        if ($ex instanceof ServerStopExceptionInterface) {
            $this->stopServerByException($ex);
        }

        return $response;
    }
578262
private function processException(Exception $exception)
    {
        $context = [
            'exception_class' => get_class($exception),
        ];

        return $this->addStackContext($exception, $context);
    }
139494
protected function mailException(Exception $exception)
    {
        $data = [
            'exception' => $exception,
            'toEmail' => config('laravelEmailExceptions.ErrorEmail.toEmailAddress'),
            'fromEmail' => config('laravelEmailExceptions.ErrorEmail.fromEmailAddress'),
        ];

        Mail::send('laravelEmailExceptions::emailException', $data, function ($message) {

            $default = 'An Exception has been thrown on '.
                config('app.name', 'unknown').' ('.config('app.env', 'unknown').')';
            $subject = config('laravelEmailExceptions.ErrorEmail.emailSubject') ?: $default;

            $message->from(config('laravelEmailExceptions.ErrorEmail.fromEmailAddress'))
                ->to(config('laravelEmailExceptions.ErrorEmail.toEmailAddress'))
                ->subject($subject);
        });
    }
1322901
public final boolean verifyEventCondition(MessageEnvelope envelope) {
		String message = safeGetQuickReplyPayload(envelope);
		return expectedPattern.matcher(message).matches();
	}
1176233
protected function doProcess(Exchange $exchange, SerializableArray $processingContext)
    {
        try {
            return $this->processor->process($exchange);
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(
                'Processor could not process exchange: '.$e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }
768499
private function failIfNotMerged(Envelope $envelope)
    {
        if (!$this->tracker->has($envelope)) {
            throw ApiException::createNotMerged($envelope);
        }
    }
332912
public static function sendException(\Exception $e, ServiceRequestInterface $request = null)
    {
        $response = static::exceptionToServiceResponse($e);

        return ResponseFactory::sendResponse($response, $request);
    }
644873
public function handle_exception(Exception $e)
    {
        if ($e instanceof DailymotionAuthException) {
            $e = new Bridge_Exception_ActionAuthNeedReconnect($e->getMessage());
        } elseif ($e instanceof DailymotionApiException || $e instanceof DailymotionAuthRequiredException) {
            $e = new Exception($e->getMessage(), $e->getCode());
        }

        return;
    }
522300
protected function doProcess(Exchange $exchange, SerializableArray $processingContext)
    {
        if (empty($this->exceptionClass)) {
            throw new \RuntimeException('Exception class not found');
        }

        /** @var ExchangeAwareInterface $exception */
        $exception = new $this->exceptionClass($this->exceptionMessage);

        throw $exception;
    }
667582
public function sendEmail(Exception $exception)
    {
        try {
            $e = FlattenException::create($exception);
            $handler = new SymfonyExceptionHandler();
            $html = $handler->getHtml($e);

            Mail::send(new ExceptionOccured($html));
        } catch (Exception $exception) {
            Log::error($exception);
        }
    }
275337
public function sendException(\Exception $exception)
  {
    $this->setStatusCode($exception->getCode(), $exception->getMessage());

    $this->setJsonContent($this);

    return parent::send();
  }
1068605
public function throwServiceExceptionFromViolationException(ValidationException $exception)
    {
        $message = 'Invalid input given';

        if ($exception->getViolations()->count() === 1) {
            $message = $exception->getViolations()->get(0)->getMessage();
        }

        throw new InputException($message, 0, $exception);
    }