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

framework exceptions & illuminate/log #171

Closed
Broutard opened this Issue Nov 27, 2018 · 12 comments

Comments

3 participants
@Broutard
Copy link

Broutard commented Nov 27, 2018

With illuminate/log loaded, a missing command argument produce (even in production) :

[2018-11-27 13:18:15] development.ERROR: Not enough arguments (missing: "database"). {"exception":"[object] (Symfony\\Component\\Console\\Exception\\RuntimeException(code: 0): Not enough arguments (missing: \"database\"). at /var/www/www2/wbcmd/vendor/symfony/console/Input/Input.php:76)
[stacktrace]
#0 /var/www/www2/wbcmd/vendor/symfony/console/Command/Command.php(250): Symfony\\Component\\Console\\Input\\Input->validate()
#1 /var/www/www2/wbcmd/vendor/illuminate/console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#2 /var/www/www2/wbcmd/vendor/symfony/console/Application.php(893): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#3 /var/www/www2/wbcmd/vendor/symfony/console/Application.php(262): Symfony\\Component\\Console\\Application->doRunCommand(Object(App\\Commands\\Db\\Restore), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#4 /var/www/www2/wbcmd/vendor/symfony/console/Application.php(145): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#5 /var/www/www2/wbcmd/vendor/illuminate/console/Application.php(89): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#6 /var/www/www2/wbcmd/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#7 /var/www/www2/wbcmd/vendor/laravel-zero/framework/src/Kernel.php(76): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#8 /var/www/www2/wbcmd/wbcmd(37): LaravelZero\\Framework\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#9 {main}
"}


  Not enough arguments (missing: "database").

without illuminate/log loaded, it produce only

  Not enough arguments (missing: "database").

Is there a way to handle this kind of error ? (be able to log into my commands but not the framework exceptions).

@nunomaduro

This comment has been minimized.

Copy link
Member

nunomaduro commented Nov 27, 2018

Sorry buddy, you will have to detail your problem better.

Can you re-phrase it?

@Broutard

This comment has been minimized.

Copy link
Author

Broutard commented Nov 27, 2018

Ok, sorry.

After adding illuminate/log with your app:install log command , when I run a command without passing the required argument, an exception occured in vendor/symfony/console/Command/Command.php and the stacktrace is dumped into stderr (the default stack in my config/logging.php config file).

It's not a problem in development but it's not very clean in production.

Is there a way to handle the framework exceptions in production (at least) ?

@Broutard Broutard changed the title missing argument with illuminate/log framework exceptions & illuminate/log Nov 27, 2018

@nunomaduro

This comment has been minimized.

Copy link
Member

nunomaduro commented Nov 27, 2018

@Broutard Change the log driver is not a solution?

@Broutard

This comment has been minimized.

Copy link
Author

Broutard commented Nov 27, 2018

And if I want to be able to use Log::error($message) in my command ?

Maybe you should add an exception handler to choose the kind of exception to render (and the rendering format).

@nunomaduro

This comment has been minimized.

Copy link
Member

nunomaduro commented Nov 27, 2018

@Broutard I am not sure what you are trying to accomplish. You are just trying to display errors in your console? For that you can use $this->error($message) instead.

@Broutard

This comment has been minimized.

Copy link
Author

Broutard commented Nov 27, 2018

I want to log error (with syslog for example) in production, if an error occured in my commands... but not if any user miss to pass an argument.

@nunomaduro

This comment has been minimized.

Copy link
Member

nunomaduro commented Dec 22, 2018

@Broutard You may have to implement your own exception handler, to not report those exceptions.

@nunomaduro nunomaduro added the question label Dec 22, 2018

@digitalkreativ

This comment has been minimized.

Copy link

digitalkreativ commented Jan 8, 2019

@Broutard this seemed like a good issue for me to find out how to do it.

I got a basic implementation up and running. I can get it up on github, if you need it.

I will also probably write an article on my blog for this soon. One of my new years resolutions was to start writing more so this seems like a good start :)

@nunomaduro if needed I can add some basic info on how to write your own ExceptionHandler to the docs.

@nunomaduro

This comment has been minimized.

Copy link
Member

nunomaduro commented Jan 8, 2019

@digitalkreativ Documentation about this would be perfect. You don't mind?

@digitalkreativ

This comment has been minimized.

Copy link

digitalkreativ commented Jan 8, 2019

@nunomaduro the basic info on that shouldn't be to hard to write up, so no problem.

Where do you want it in the menu structure? Inside the Usage menu I assume?

@nunomaduro

This comment has been minimized.

Copy link
Member

nunomaduro commented Jan 8, 2019

@digitalkreativ Just propose a pull request. We work from that.

Probably inside a new topic called "The Exception Handler" - where you explain that laravel zero uses one by default on the core, but you can override it blabla.

@digitalkreativ

This comment has been minimized.

Copy link

digitalkreativ commented Jan 12, 2019

@Broutard the latest documentation should help you solve your problem.

https://laravel-zero.com/docs/exception-handler/

If you get stuck somewhere in the documentation let me know and I'll see if I can help you and update documentation if necessary.

@nunomaduro nunomaduro closed this Feb 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment