Creates an exception for the given option name.

@param string    $name  The option name.
@param int       $code  The exception code.
@param Exception $cause The exception that caused this exception.

@return static The created exception.
513925
public static function forOptionName($name, $code = 0, Exception $cause = null)
    {
        return new static(sprintf(
            'The option "%s%s" does not exist.',
            strlen($name) > 1 ? '--' : '-',
            $name
        ), $code, $cause);
    }
535771
private static LSException createLSException(short code, Throwable cause) {
        LSException lse = new LSException(code, cause != null ? cause.getMessage() : null);
        if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
            try {
                ThrowableMethods.fgThrowableInitCauseMethod.invoke(lse, new Object [] {cause});
            }
            // Something went wrong. There's not much we can do about it.
            catch (Exception e) {}
        }
        return lse;
    }
1284645
protected function render(Exception $exception, array $info, int $code)
    {
        $view = $this->factory->make("errors.{$code}", $info);

        return $view->with('exception', $exception)->render();
    }
1197917
public function create($code, $name)
    {
        $transformer = new CreateTransformer($code, $name);
        $body        = $transformer->output();

        /** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
        $responseHandler = $this->service()->post($this->baseUrlPath(), $body);

        return $responseHandler;
    }
208786
public static function addStatus($code, $name)
    {
        self::$HTTP_STATUS_CODES[$code] = $name;
        self::addCodeName($name);
    }
473539
protected function createComponent($name)
    {
        $result = null;

        $config = $this->getComponentConfig($name);

        if ($config !== null && isset($config['class'])) {
            $result = new $config['class'];
            if (!($result instanceof \pwf\basic\interfaces\Component)) {
                throw new \Exception('Component must implement \'Component\' interface',
                500);
            }
            $result->loadConfiguration($config);
        }

        return $result;
    }
1217037
public function throwError($string, $code = 500, $e = null)
    {
        if (!$this->isFullException() || is_null($e)) {
            throw new \Exception($string, $code);
        } else {
            throw new \Exception($string . ": " . $e->getMessage(), $code);
        }
    }
834637
public function create(string $name)
    {
        if ($this->locator->has($name)) {
            return $this->locator->get($name);
        }

        throw new \Exception(\sprintf('Filter "%s" was not found.', $name));
    }
1029473
public function httpError($code)
    {
        switch ($code)
        {
            case 400:
                throw new Eresus_HTTP_Exception_BadRequest;
            case 401:
                throw new Eresus_HTTP_Exception_Unauthorized;
            case 402:
                throw new Eresus_HTTP_Exception_PaymentRequired;
            case 403:
                throw new Eresus_HTTP_Exception_Forbidden;
            case 404:
                throw new Eresus_HTTP_Exception_NotFound;
            default:
                throw new Eresus_HTTP_Exception('', $code);
        }
    }
394185
protected function _createI18nException($message, $code = 0, \Exception $previous = null)
    {
        return new I18nException($message, $code, $previous);
    }
974972
public static function makeFromException($e, $overrideCode = null)
    {
        $code = $overrideCode === null ? $e->getCode() : $overrideCode;

        if ($e instanceof static) {
            $e->code = $code;

            return $e;
        }

        return new static($e->getMessage(), $code, $e);
    }
278041
public function handleError($error, $code, $path, $source, $parameters, $options)
    {
        /* @var \Throwable $error */
        $exception = $options['debug']
            ? $this->getDebuggedException($error, $code, $source, $path, $parameters, $options)
            : $error;

        $handler = $options['error_handler'];
        if (!$handler) {
            // @codeCoverageIgnoreStart
            if ($options['debug'] && $options['exit_on_error']) {
                if ($options['html_error']) {
                    echo $exception->getMessage();
                    exit(1);
                }
                if (!function_exists('xdebug_is_enabled') || !xdebug_is_enabled()) {
                    echo $exception->getMessage()."\n".$exception->getTraceAsString();
                    exit(1);
                }
            }
            // @codeCoverageIgnoreEnd
            throw $exception;
        }

        $handler($exception);
    }
1118336
public static function createFromException($e, $level, array $context = [])
    {
        return new static($e->getMessage(), $level, $context, $e->getCode(), $e->getPrevious());
    }
88368
protected function _createTranslationException($message, $code = 0, \Exception $previous = null, $subject = null, TranslatorInterface $translator = null)
    {
        return new TranslationException($message, $code, $previous, $subject, $translator);
    }
199302
public static function make($errorCode, $errorMessage)
    {
        $exception = Arr::get(self::$supported, $errorCode, Errors\Error::class);

        return new $exception($errorMessage, $errorCode);
    }
1231068
public function setOption($name, $value)
    {
        if (!is_string($name)) {
            throw new Exception('invalid options name');
        }
        $name = strtolower($name);
        if ($name == 'result_store') {
            $this->options['result_store'] = $value;
            $this->setResultStore($value);
        } elseif ($name == 'broker') {
            $this->options['broker'] = $value;
            $this->setBroker($value);
        }
        return $this;
    }
961554
public static function existsAlready($name, Exception $cause = null)
    {
        return new static(sprintf(
            'An option named "%s%s" exists already.',
            strlen($name) > 1 ? '--' : '-',
            $name
        ), 0, $cause);
    }