Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(console): do not override error handler on console requests #25

Open
wants to merge 1 commit into
base: 4.x.dev
Choose a base branch
from

Conversation

nstCactus
Copy link

Disable the Canary error handler in console requests in order to fix an issue when running a console command that triggers an error.

Example: running the ./craft non-existing-module/non-existing-controller/non-existing-action, yields:

An Error occurred while handling another error:
yii\base\UnknownMethodException: Calling unknown method: craft\console\Request::getAcceptsJson() in /var/www/html/craft/vendor/yiisoft/yii2/base/Component.php:300
Stack trace:
#0 /var/www/html/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(130): yii\base\Component->__call('getAcceptsJson', Array)
#1 /var/www/html/craft/vendor/topshelfcraft/canary/src/ErrorHandler.php(15): craft\web\ErrorHandler->renderException(Object(yii\console\UnknownCommandException))
#2 /var/www/html/craft/vendor/yiisoft/yii2/base/ErrorHandler.php(152): TopShelfCraft\Canary\ErrorHandler->renderException(Object(yii\console\UnknownCommandException))
#3 /var/www/html/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(66): yii\base\ErrorHandler->handleException(Object(yii\console\UnknownCommandException))
#4 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\console\UnknownCommandException))
#5 {main}
Previous exception:
yii\base\InvalidRouteException: Unable to resolve the request "non-existing-module/non-existing-controller/non-existing-action". in /var/www/html/craft/vendor/yiisoft/yii2/base/Module.php:561
Stack trace:
#0 /var/www/html/craft/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('non-existing-mo...', Array)
#1 /var/www/html/craft/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('non-existing-mo...', Array)
#2 /var/www/html/craft/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('non-existing-mo...', Array)
#3 /var/www/html/craft/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#4 /var/www/html/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#5 /var/www/html/craft/craft(29): yii\base\Application->run()
#6 {main}

Next yii\console\UnknownCommandException: Unknown command "non-existing-module/non-existing-controller/non-existing-action". in /var/www/html/craft/vendor/yiisoft/yii2/console/Application.php:183
Stack trace:
#0 /var/www/html/craft/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('non-existing-mo...', Array)
#1 /var/www/html/craft/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('non-existing-mo...', Array)
#2 /var/www/html/craft/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#3 /var/www/html/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#4 /var/www/html/craft/craft(29): yii\base\Application->run()
#5 {main}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant