scribe icon indicating copy to clipboard operation
scribe copied to clipboard

[Feature request]: Make exception handling configurable

Open mortenscheel opened this issue 11 months ago • 2 comments

Scribe version

4.38.0

Your question

Motivation

If a model generation strategy fails, a warning is printed in the console:

⚠ Couldn't get example model for App\Models\Whatever via factoryCreate.
  1. This message can be hard to spot, since scribe's output is quite verbose.
  2. The only way to discover why the generation failed, is by running scribe:generate with xdebug, while having a breakpoint at https://github.com/knuckleswtf/scribe/blob/cb4c2e552fdae4fd2306e12bba60d5de38a9e4ad/src/Extracting/InstantiatesExampleModels.php#L56

Suggestions

  1. The message is printed with the same severity as something like No bodyParameters() method found.... I think it would be appropriate to print it in red.
  2. Add one or more configuration options for how these errors should be handled. Options could be something like: a. warn: (default, same as current behavior) b. dump: dump the exception to console, but continue execution c. fail: dump the exception to console, and abort with an exit code

Docs

mortenscheel avatar Jan 10 '25 10:01 mortenscheel

Do you have an example of what Scribe's output looks like for you, so I can understand how verbose it is in context?

shalvah avatar Jan 18 '25 18:01 shalvah

@shalvah sorry for the delay. Sure, here's an excerpt of the output where one of the factories fail:

Image

mortenscheel avatar Jan 29 '25 11:01 mortenscheel

This would be closed by https://github.com/knuckleswtf/scribe/pull/964

brianferri avatar Mar 04 '25 13:03 brianferri

Sweet. Thanks!

mortenscheel avatar Mar 05 '25 09:03 mortenscheel