Check if this schedule can be run

@param bool $throwException
@return bool
@throws Exception
@throws Mage_Core_Exception
162205
public function canRun($throwException = false)
    {
        if ($this->isAlwaysTask()) {
            return true;
        }
        $now = time();
        $time = strtotime($this->getScheduledAt());
        if ($time > $now) {
            // not scheduled yet
            return false;
        }
        $scheduleLifetime = Mage::getStoreConfig(Mage_Cron_Model_Observer::XML_PATH_SCHEDULE_LIFETIME) * 60;
        if ($time < $now - $scheduleLifetime) {
            $this->setStatus(Aoe_Scheduler_Model_Schedule::STATUS_MISSED);
            $this->save();
            if ($throwException) {
                Mage::throwException(Mage::helper('cron')->__('Too late for the schedule.'));
            }
            return false;
        }
        return true;
    }
769231
public function run()
    {
        for ($i = 1; $i <= $this->maxRetry; $i++) {
            try {
                return call_user_func_array($this->process, $this->args);
            } catch (\Exception $e) {
                if (in_array(get_class($e), $this->allowedExceptions)) {
                    throw $e;
                }
            }

            if ($i < $this->maxRetry) {
                sleep($this->timeout);
                $this->logger->warning(sprintf('[%s] Can\'t perform action, retrying [%s/%s]', $this->logInfos['callable'], $i, $this->maxRetry));
            } else {
                $this->logger->error(sprintf('[%s] %s retry has failed, aborting [%s/%s]', $this->logInfos['callable'], $i, $this->maxRetry));
                $retryException = new YoloException('', 0, $e);
                $retryException->setRetry($this->maxRetry);
                $retryException->setTimeout($this->timeout);
                throw $retryException;
            }
        }
    }
764606
public function setPHPThrowable($throwable)
    {
        if (!$throwable instanceof Throwable && !$throwable instanceof Exception) {
            throw new InvalidArgumentException('The throwable must implement Throwable or extend Exception.');
        }

        $this->setName(get_class($throwable))
             ->setMessage($throwable->getMessage())
             ->setStacktrace(Stacktrace::fromBacktrace($this->config, $throwable->getTrace(), $throwable->getFile(), $throwable->getLine()));

        if (method_exists($throwable, 'getPrevious')) {
            $this->setPrevious($throwable->getPrevious());
        }

        return $this;
    }
1177228
public function call(ActionInterface $action, $throwsException = true)
    {
        try {
            $this->checkSecurity();

            $result = call_user_func_array([$this->soapClient, $action->getMethod()], array_merge([$this->sessionId], $action->getArguments()));
            return $result;

        } catch (\Exception $e) {
            if ($throwsException) {
                throw $e;
            }

            return false;
        }
    }
689651
function run() {
		$this->scheduled = false; ++$this->tries; $progress = 0;
		while ( ! $this->finished() ) {
			if ( $this->ready() && $this->run_next_step() ) {
				$progress++;
			} else {
				$this->schedule();
				return $progress;
			}
		}
		return true;
	}
689908
public function willThrowException(\Throwable $exception): self
    {
        if ($this->hasReturnSelf) {
            throw new \InvalidArgumentException(sprintf('%s: There is already a return self', __METHOD__));
        }

        if ($this->hasReturn) {
            throw new \InvalidArgumentException(sprintf('%s: There is already a return', __METHOD__));
        }

        if ($this->hasReturnCallback) {
            throw new \InvalidArgumentException(sprintf('%s: There is already a return callback', __METHOD__));
        }

        $this->exception = $exception;

        return $this;
    }
13113
public function andRun()
    {
        if ($this->_returns) {
            throw new Exception("Some return value(s) has already been set.");
        }
        $closures = func_get_args();
        foreach ($closures as $closure) {
            if (!is_callable($closure)) {
                throw new Exception("The passed parameter is not callable.");
            }
        }
        $this->_closures = $closures;
    }
394484
public function isJsonProperty($property, $throwException = false)
    {
        if(is_string($property) && in_array($property, $this->properties))
            return true;

        if($throwException)
            throw new JsonPropertyException("Requested property '{$property}' is not a valid for '".get_class($this)."'.");

        return false;
    }
234816
private function isResumableError(RuntimeException $exception)
    {
        if ($exception instanceof ConnectionException) {
            return true;
        }

        if ( ! $exception instanceof ServerException) {
            return false;
        }

        if (in_array($exception->getCode(), [self::$errorCodeCappedPositionLost, self::$errorCodeCursorKilled, self::$errorCodeInterrupted])) {
            return false;
        }

        return true;
    }
1207499
protected function handleException(\Throwable $exception, RequestInterface $request): RequestException
    {
        if ($exception instanceof RequestException) {
            return $exception;
        }

        return new RequestException($request, $exception);
    }
368390
protected static function validate_course($courseorid, $throwexception = true) {
        $course = $courseorid;
        if (!is_object($course)) {
            $course = get_course($course);
        }

        $coursecontext = context_course::instance($course->id);
        if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
            if ($throwexception) {
                throw new require_login_exception('Course is hidden');
            } else {
                return false;
            }
        }

        return true;
    }
611178
public function exceptionHandler($throwable)
    {
        $report = Report::fromPHPThrowable(
            $this->client->getConfig(),
            $throwable
        );

        $report->setSeverity('error');
        $report->setUnhandled(true);
        $report->setSeverityReason([
            'type' => 'unhandledException',
        ]);

        $this->client->notify($report);

        if ($this->previousExceptionHandler) {
            call_user_func(
                $this->previousExceptionHandler,
                $throwable
            );
        }
    }
31184
public function tryLock($taskCallable = null)
    {
        if($this->isLocked())
        {
            return false;
        }
        if(!$this->__tryLock())
        {
            return false;
        }
        if(null === $taskCallable)
        {
            return true;
        }
        else
        {
            try {
                $taskCallable();
            } catch (\Throwable $th) {
                throw $th;
            } finally {
                $this->unlock();
            }
        }
    }
850556
public function wait()
    {
        if ($this->process == null) {
            throw new \Exception('You must run `start` before running `wait`');
        }

        // blocks here until process completes
        $this->process->wait();

        if (!$this->process->isSuccessful()) {
            throw new \RuntimeException($this->process->getErrorOutput());
        }

        return $this->process->getOutput();
    }
104267
public function fail(\Throwable $throwable)
    {
        Logger::get()->exception($throwable);
        header('Server error', true, 500);
        echo '<h1>Eix</h1>';
        echo 'The application cannot continue.';
        echo '<blockquote>' . $throwable->getMessage() . '</blockquote>';

        if (defined('DEBUG') && DEBUG) {
            echo '<pre>' . $throwable->getTraceAsString() . '</pre>';
        }

        die(-1);
    }
890155
public function handleException( \Throwable $e ) : bool
    {
        // Render exception
        $output = $this->renderer->output( $e );
    
        // output
        fwrite(STDERR, $output . PHP_EOL);
    
        return true;
    }
1326644
public function multiCall(MultiCallQueueInterface $queue, $throwsException = true)
    {
        try {
            $this->checkSecurity();

            $actions = $this->getActions($queue);
            $results = $this->soapClient->multiCall($this->sessionId, $actions);

            $this->handleCallbacks($queue, $results);

            return $results;

        } catch (\Exception $e) {
            if ($throwsException) {
                throw $e;
            }

            return false;
        }
    }