{@inheritdoc}
@throws \Exception
179469
public function run()
    {
        $html = $this->renderButton() . "\n" . $this->renderDropdown();

        if ($this->renderContainer) {
            Html::addCssClass($this->options, ['widget' => 'drop'.$this->direction, 'btn-group']);
            $options = $this->options;
            $tag = ArrayHelper::remove($options, 'tag', 'div');
            $html = Html::tag($tag, $html, $options);
        }

        // Set options id to button options id to ensure correct css selector in plugin initialisation
        $this->options['id'] = $this->buttonOptions['id'];

        $this->registerPlugin('dropdown');
        return $html;
    }
1211173
public function run() {
		if ($this->url === null) {
			throw new \Exception("No URL configured for redirection.");
		}
		if (strpos($this->url, '/') === 0 || strpos($this->url, 'http://') === 0 || strpos($this->url, 'https://') === 0) {
			$url = ValueUtils::val($this->url);
		} else {
			$url = ROOT_URL.ValueUtils::val($this->url);
		}
		header("Location: ".$url);
	}
883544
public function execute($data) {

        try {
            $config = $this->sanitizeConfig($data);
            $this->isConciliate($config);
            if (! $this->doCancel($config))
                throw new \Exception('impossible to cancel.');

            $this->doUpdates($config);
            return true;
        } catch (\Exception $exception) {
            throw $exception;
        }
    }
295585
public function handleException($exception) {
		if(!$this->isStarted || $this->isHandlingDisabled()) {
			return;
		}
		try {
			$this->onHandlingStart();
			$this->connector->getErrorsDispatcher()->dispatchException($exception);
			if($this->oldExceptionsHandler && $this->callOldHandlers) {
				call_user_func($this->oldExceptionsHandler, $exception);
			}
		}
		catch(\Throwable $internalException) {
			$this->handleException($internalException);
		}
		catch(\Exception $internalException) {
			$this->handleException($internalException);
		}
		$this->onHandlingComplete();
	}
449661
public function fire()
    {
        $model = $this->argument('model');

        if(is_subclass_of($model, $this->baseClassName))
        {
            $model::removeExpired();
        }
        else
        {
            throw new \Exception('The specified class ('.$model.') does not extend '.$this->baseClassName);
        }
    }
535509
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\Class_ || ! $parent instanceof PhpFileModelInterface) {
            throw new Exception('ClassNodeParser is made to parse a class node');
        }
        $class = new ClassModel();
        $class->setParentNode($parent);
        $class->setName(ClassLikeNameHelper::getName($node));
        $class->setIsAbstract($node->isAbstract());
        $class->setIsFinal($node->isFinal());
        $parent->addConcreteUse($parent->getFullNameFor($class->getName()), $class->getName());

        if (($documentation = $node->getDocComment()) !== null) {
            $this->documentationNodeParser->invoke($documentation, $class);
        }

        $this->parseSubNodes($node->stmts, $class);

        $parent->addClass($class);
    }
992880
public function run()
    {
        if (!$this->isAppRootSet()) {
            throw new Exception("The application root wasn't defined.", 1);
        }
        if (!$this->isConfigFileSet()) {
            throw new Exception("The main config file wasn't defined.", 2);
        }
        $sConfigPath = $this->getAppRoot().$this->getConfigFile();
        if (!is_readable($sConfigPath)) {
            throw new Exception("It's unable to load ".$sConfigPath
            .'as main config file.', 4);
        }
        $mConfig = include $sConfigPath;
        if (!is_array($mConfig)) {
            throw new Exception('The main config must be an array.', 5);
        }
        $this->configSet = $mConfig;
    }
209466
public function setException(exception $e)
    {
        if (isset($this->response)) {
            $this->response->setException($e);
        } else {
            throw $e;
        }
    }
1019073
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\Namespace_ || ! $parent instanceof PhpFileModelInterface) {
            throw new Exception('NamespaceNodeParser is made to parse a namespace node');
        }

        if ($node->name instanceof Node\Name) {
            $parent->setNamespace($node->name->parts);
        }

        $this->preParseUses($node->stmts, $parent);

        $this->parseSubNodes($node->stmts, $parent);
    }
1050924
public function execute()
    {
        $stmt = $this->dbh->prepare($this->__toString());

        try {
            $success = $stmt->execute($this->getValues());
            if (!$success) {
                $info = $stmt->errorInfo();

                throw new Exception($info[2], $info[0]);
            }
        } catch (PDOException $e) {
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $stmt;
    }
1118223
public function handle(Exception $exception)
    {
        try {

            $handlers = array_filter($this->handlers, function ($handler) use ($exception) {
                return $exception instanceof $handler[0];
            });

            foreach ($handlers as $handler) {
                $error = $handler[1]($exception);

                if ($error !== null) {
                    break;
                }
            }

        } catch (Exception $e) {

            echo sprintf('[%d] %s in %s', $e->getLine(), $e->getMessage(), $e->getFile());
        }
    }
1296622
public function create() {
        $migration = $this->getMessages();
        if (!$migration) {
            $this->db()->insert($this->table, array('migration' => get_class($this), 'state' => false));
        } else {
            throw new \Exception('Migration ' .  get_class($this) . ' already created');
        }
    }
256566
public function handle()
    {
        $package = $this->argument('package');
        $command = $this->argument('commandname');
        if (Package::where('name', $package)->count() > 0) {
            throw new Exception("Package with name ($package) already exist");
        }
        if (Package::where('command', $command)->count() > 0) {
            throw new Exception("Package with command ($command) already exist");
        }
        Package::create([
            'name' => $package,
            'namespace' => $this->argument('namespace'),
            'command' => $command,
        ]);
    }
486640
public function setException($path) {
        $pathException = (!is_array($path)) ? array($path) : $path;
        $this->exceptions = array_merge($this->exceptions, $pathException);
    }
864534
public function setUsername($username)
        {
            if ($this->validateUsername($username) === false) {
                throw new Exception("Username \"$username\" is not a valid HTTP username");
            }

            $oldUsername     = $this->_username;
            $this->_username = $username;

            return $oldUsername;
        }
1272392
public function handle($exception)
    {
        $handlers = (array)Configure::read('Error.config.handlers');
        foreach ($handlers as $handler => $config) {
            $handlerClass = $handler;
            if (!class_exists($handlerClass)) {
                $handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
            }
            if (!class_exists($handlerClass)) {
                $handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler . 'Handler';
            }
            if (!class_exists($handlerClass)) {
                continue;
            }
            $instance = new $handlerClass((array)$config);
            $instance->handle($exception);
        }
    }
912376
public function create($resource)
    {
        $className = $this->getResourceClassName($resource->type);
        if (!class_exists($className)) {
            throw new Exception(
                'Unknown resource type "' . $resource->type . '".',
                Exception::UNKNOWN_RESOURCE_TYPE
            );
        }

        /** @var AbstractResource $object */
        $object = $this->objectManager->get($className);

        foreach ($resource as $property => $value) {
            if (!ObjectAccess::isPropertySettable($object, $property)) {
                continue;
            }
            ObjectAccess::setProperty($object, $property, $value);
        }

        $this->postProcessResources($object);

        return $object;
    }