Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未从codeception处理异常_Php_Exception_Laravel_Codeception - Fatal编程技术网

Php 未从codeception处理异常

Php 未从codeception处理异常,php,exception,laravel,codeception,Php,Exception,Laravel,Codeception,我在global.php中处理了一个异常,但当我运行codeception时,它显示异常被抛出,但未被处理。当我使用浏览器时,一切都很好。这怎么可能呢 编码接受功能接受码 $I = new FunctionalTester($scenario); $I->am('a user'); $I->wantTo('send a message to another user'); //setup $I->haveAnAccount(['username' => 'OtherU

我在global.php中处理了一个异常,但当我运行codeception时,它显示异常被抛出,但未被处理。当我使用浏览器时,一切都很好。这怎么可能呢


编码接受功能接受码

$I = new FunctionalTester($scenario);
$I->am('a user');
$I->wantTo('send a message to another user');

//setup
$I->haveAnAccount(['username' => 'OtherUser']);

//actions
$I->signIn();
$I->click('Messages');
$I->seeCurrentUrlEquals('/inbox/new');
$I->fillField('Send to:','OtherUser');
$I->fillField('Message:','some random message');
$I->click('Send');
$I->click('Messages)时失败出现错误

Couldn't click "Messages":
Larabook\Conversations\Exceptions\ConversationNotFoundException: 
然而,我在
global.php中处理了它

App::error(function(Larabook\Conversations\Exceptions\ConversationNotFoundException $exception, $code)
{
    return Redirect::route('new_message_path');
});

它还显示了引发异常的位置:

Scenario Steps:
4. I click "Messages"
3. I sign in 
2. I have an account {"username":"OtherUser"}
1. As a a Larabook user

#1 /home/vagrant/Code/larabook.app/app/Larabook/Conversations/getConversationCommandHandler.php:41
#2  /home/vagrant/Code/larabook.app/vendor/laracasts/commander/src/Laracasts/Commander/DefaultCommandBus.php:58
#3  /home/vagrant/Code/larabook.app/vendor/laracasts/commander/src/Laracasts/Commander/ValidationCommandBus.php:64
#4  /home/vagrant/Code/larabook.app/vendor/laracasts/commander/src/Laracasts/Commander/CommanderTrait.php:34
#5  /home/vagrant/Code/larabook.app/app/controllers/InboxController.php:39
#6  /home/vagrant/Code/larabook.app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:231
#7  /home/vagrant/Code/larabook.app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:93
#8  /home/vagrant/Code/larabook.app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:62
#9  /home/vagrant/Code/larabook.app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:962
#10 /home/vagrant/Code/larabook.app/vendor/laravel/framework/src/Illuminate/Routing/Route.php:109



请用完整的提示/错误信息发布您的代码,我将其发布在@Begueradj
getConversationCommandHandler.php        

    28:    public function handle($command)
    29:    {
    30:        try
    31:         {
    32:             //get the user by username
    33:             $user = $this->userRepository->findbyUsername($command->sendToUsername);
    34:    
    35:             //get the conversation between users
    36:             $conversation = $this->conversationRepository->getConversationWith($user);
    37:         }
    38:         catch(UserNotFoundException $e)
    39:         {
    40:             //if the user not found get the last conversation
    41:             $conversation = $this->conversationRepository->getLastConversation();
    42:         }
    43:         catch(ConversationNotFoundException $e)
    44:         {
    45:             //if the conversation not found get the last conversation
    46:             $conversation = $this->conversationRepository->getLastConversation();
    47:         }
    48:
    59:         return $conversation;
    50:         }