Исключение не обрабатывается из кодирования

Я обработал исключение в global.php, но когда я запускаю codeception, он показывает, что Exception выброшен, но не обработан. Когда я использую браузер, все отлично работает. Как это могло быть возможно?


Функциональная кодировка Cept code

$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

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:         }

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …