public static function create($name)
    {
        $class = App::className($name, 'Middleware/UnauthorizedHandler', 'Handler');
        if (!$class) {
            $message = sprintf('Handler `%s` does not exist.', $name);
            throw new RuntimeException($message);
        }

        $instance = new $class();
        if (!$instance instanceof HandlerInterface) {
            $message = sprintf('Handler should implement `%s`, got `%s`.', HandlerInterface::class, get_class($instance));
            throw new RuntimeException($message);
        }

        return $instance;
    }