src/Listener/ApiListener.php
protected function _exceptionResponse(Event $Event, $exceptionConfig)
    {
        $exceptionConfig = array_merge($this->getConfig('exception'), $exceptionConfig);

        $class = $exceptionConfig['class'];

        if ($exceptionConfig['type'] === 'validate') {
            $exception = new $class($Event->getSubject()->entity);
            throw $exception;
        }

        $exception = new $class($exceptionConfig['message'], $exceptionConfig['code']);
        throw $exception;
    }
protected function _exceptionResponse(Event $Event, $exceptionConfig)
    {
        $exceptionConfig = array_merge($this->getConfig('exception'), $exceptionConfig);

        $class = $exceptionConfig['class'];

        if ($exceptionConfig['type'] === 'validate') {
            $exception = new $class($Event->getSubject()->entity);
            throw $exception;
        }

        $exception = new $class($exceptionConfig['message'], $exceptionConfig['code']);
        throw $exception;
    }
protected function _exceptionResponse ( Event $ Event , $ exceptionConfig ) { $ exceptionConfig = array_merge ( $ this -> getConfig ( 'exception' ) , $ exceptionConfig ) ; $ class = $ exceptionConfig [ 'class' ] ; if ( $ exceptionConfig [ 'type' ] === 'validate' ) { $ exception = new $ class ( $ Event -> getSubject ( ) -> entity ) ; throw $ exception ; } $ exception = new $ class ( $ exceptionConfig [ 'message' ] , $ exceptionConfig [ 'code' ] ) ; throw $ exception ; }
Throw an exception based on API configuration

@param \Cake\Event\Event $Event Event
@param array $exceptionConfig Exception config
@return void
@throws \Exception
Throw an exception based on API configuration