knuckleswtf/scribe

Exceptions during Model factory creation for API endpoints are never printed -- no matter verbose setting

Opened this issue · 1 comments

Scribe version

4.37.0

PHP version

8.2

Framework

Laravel

Framework version

11.12.0

Scribe config

title => "API Documentation"
auth.name => "Authorization"
strategies.responses => added [
    'Knuckles\\Scribe\\Extracting\\Strategies\\Responses\\ResponseCalls',
    [
        'only' => [
            'GET *',
        ],
    ],
]: removed [
    'Knuckles\\Scribe\\Extracting\\Strategies\\Responses\\ResponseCalls',
    [
        'only' => [
            'GET *',
        ],
        'config' => [
            'app.debug' => false,
        ],
    ],
]

What happened?

Reproduce

  • I run php artisan scribe:generate -vvv (or php artisan scribe:generate --verbose)
  • I see some warnings for my models like "Couldn't get example model App\Model[modelname] via factoryCreate
  • I expected to see exception output (and stack trace) for each of these warnings, so I can debug the issue, but I only get the warning.

Explanation/analysis

The reason there is no exception output is that $completelySilent parameter for the function dumpExceptionIfVerbose is always set to true in the model factory exception handler:

e::dumpExceptionIfVerbose($e, true);

Possible fix

I would expect that the parameter $completelySilent should either be absent or false in the code mentioned above. When I go to the vendor/ source and change that line to false, I get the stacktrace and exception output as expected.

I can submit a PR for this, if you agree with my analysis.

Docs

Yeah, I think the reason for that was to limit noise, since model instantiation was not very customizable in the past. But you're correct, this shouldn't swallow exceptions. PR welcome 👍