@param HandlerInterfaceException $handler

@return $this
775954
public function importResponseExceptionHandler(HandlerInterfaceException $handler)
    {
        $this->setCustomMessage('Error in request.');
        $this->data = array_merge($this->data, $handler->export());
        
        return $this;
    }
1205198
protected function makeClosure($handler)
    {
        if (is_callable($handler)) {
            return $handler;
        }

        if (is_string($handler)) {
            if (!class_exists($handler)) {
                throw new InvalidArgumentException(sprintf('Class "%s" not exists.', $handler));
            }

            if (!in_array(EventHandlerInterface::class, (new \ReflectionClass($handler))->getInterfaceNames(), true)) {
                throw new InvalidArgumentException(sprintf('Class "%s" not an instance of "%s".', $handler, EventHandlerInterface::class));
            }

            return function ($payload) use ($handler) {
                return (new $handler($this->app ?? null))->handle($payload);
            };
        }

        if ($handler instanceof EventHandlerInterface) {
            return function () use ($handler) {
                return $handler->handle(...func_get_args());
            };
        }

        throw new InvalidArgumentException('No valid handler is found in arguments.');
    }
668910
protected static function createMigration(HandlerInterface $handler)
    {
        $migrator = static::$migrator;
        $notifier = new Notifier();

        $migration = $migrator->createMigration(
            strtolower($handler->getName()),
            $handler->getTemplate(),
            $handler->getReplace()
        );

        $migrator->logSuccessfulMigration($migration);
        $notifier->newMigration($migration);
    }
124895
public function addHandler($handler)
    {
        if ($this->handlerLock) {
            throw new \RuntimeException('Session handlers can’t be added once the stack is dequeuing');
        }
        if (is_null($this->handlers)) {
            $this->seedHandlerStack();
        }

        // DELETE
        $next_delete = $this->stacks['delete']->top();
        $this->stacks['delete'][] = function($session_id) use ($handler, $next_delete) {
            return call_user_func(array( $handler, 'delete'), $session_id, $next_delete);
        };

        // CLEAN
        $next_clean = $this->stacks['clean']->top();
        $this->stacks['clean'][] = function($lifetime) use ($handler, $next_clean) {
            return call_user_func(array( $handler, 'clean'), $lifetime, $next_clean);
        };

        // CREATE
        $next_create = $this->stacks['create']->top();
        $this->stacks['create'][] = function($path, $name) use ($handler, $next_create) {
            return call_user_func(array( $handler, 'create'), $path, $name, $next_create);
        };

        // READ
        $next_read = $this->stacks['read']->top();
        $this->stacks['read'][] = function($session_id) use ($handler, $next_read) {
            return call_user_func(array( $handler, 'read'), $session_id, $next_read);
        };

        // WRITE
        $next_write = $this->stacks['write']->top();
        $this->stacks['write'][] = function($session_id, $session_data) use ($handler, $next_write) {
            return call_user_func(array( $handler, 'write'), $session_id, $session_data, $next_write);
        };

        return $this;
    }
534498
public function addUserAgentHandler(WURFL_Handlers_Handler $handler)
    {
        $size = count($this->_userAgentHandlers);
        if ($size > 0) {
            $this->_userAgentHandlers[$size-1]->setNextHandler($handler);
        }
        $this->_userAgentHandlers[] = $handler;
        return $this;
    }
223857
public function addListener($name, callable $handler)
    {
        $this->assertEventName($name);
        $this->getEventDispatcher()->addListener($name, $handler);
        return $this;
    }
30901
public function setRequestHandler(RequestHandler $handler)
    {
        $handlerName = $handler->getName();
        $this->handlers[$handlerName] = $handler;
        return $this;
    }
639016
public function afterHandlerSelected(AbstractHandler $handler)
    {
        parent::afterHandlerSelected($handler);

        $auth = $this->get($this->authKey);
        if (!($auth instanceof AuthenticatorInterface)) {
            throw new InternalErrorException(sprintf(
                "Implementation of AuthenticationInterface required. Please check your %s configuration.",
                $this->authKey
            ));
        }

        if (!($credentials = $this->getCredentials())) {
            throw new UnauthorizedException("Authentication is required to access this resource.");
        }

        if (!$auth->authenticate($credentials)) {
            throw new UnauthorizedException("Authentication is required to access this resource.");
        }
    }
1037646
protected function setHandler(ServerRequestInterface $request, $handler): ServerRequestInterface
    {
        return $request->withAttribute($this->attribute, $handler);
    }
683879
public function addHandler(HandlerInterface $handler, $priority = 0)
    {
        if (filter_var($priority, FILTER_VALIDATE_INT) === false) {
            throw new InvalidArgumentException("Argument 'priority' should be an integer, got '$priority'");
        }

        if ($this->handlerAlreadyRegistered($handler)) {
            return;
        }

        $this->handlers[$priority][] = $handler;
    }
1254514
public function setHandler(AbstractHandler $handler)
    {
        $handler->setErrorHandler($this);
        $this->handler = $handler;

        return $this;
    }
1025785
public function setHandler($handler = null)
    {
        $this->handler = null !== $handler ? (string)$handler: $handler;

        return $this;
    }
1326661
public function setHandler(MultiResponseHandlerInterface $handler = null):MultiRequest {

		if(!$handler){

			if(!class_exists($this->options->handler)){
				throw new RequestException('no handler set');
			}

			$handler = new $this->options->handler($this);

			if(!is_a($handler, MultiResponseHandlerInterface::class)){
				throw new RequestException('handler is not a MultiResponseHandlerInterface');
			}

		}

		$this->multiResponseHandler = $handler;

		return $this;
	}
498467
public function getHandler(string $handler): Handler
    {
        if (!isset($this->handlers[$handler])) {
            if (!class_exists($handler) || !class_implements($handler, Handler::class)) {
                throw new \RuntimeException("No handler found for '$handler'.");
            }

            $instance = new $handler();
            $this->handlers[$handler] = $instance;
        } else {
            $instance = $this->handlers[$handler];
        }

        return $instance;
    }
656888
public function create(callable $handler): callable
    {
        foreach ($this->wrappers as $wrapper) {
            $handler = $wrapper->wrap($handler);
        }

        return $handler;
    }
787338
public function group(string $prefix, callable $handler) : RouterInterface {
        $this->setPrefix($prefix);
        $handler($this);
        $this->setPrefix('');
        return $this;
    }
893333
public function process(RequestInterface $request, RequestHandlerInterface $handler)
    {
        $url = $request->getSequentialParam(1);

        $this->router->route($url, 'execute');

        return $handler->handle($request);
    }