|
@@ -20,8 +20,8 @@ use Knuckles\Scribe\Tools\AnnotationParser as a;
|
|
|
use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
|
|
|
use Knuckles\Scribe\Tools\ErrorHandlingUtils as e;
|
|
|
use Knuckles\Scribe\Tools\Utils;
|
|
|
-use Mpociot\Reflection\DocBlock;
|
|
|
use Mpociot\Reflection\DocBlock\Tag;
|
|
|
+use Throwable;
|
|
|
|
|
|
/**
|
|
|
* Parse an Eloquent API resource response from the docblock ( @apiResource || @apiResourcecollection ).
|
|
@@ -187,23 +187,23 @@ class UseApiResourceTags extends Strategy
|
|
|
|
|
|
try {
|
|
|
return $factory->create();
|
|
|
- } catch (Exception $e) {
|
|
|
+ } catch (Throwable $e) {
|
|
|
// If there was no working database, ->create() would fail. Try ->make() instead
|
|
|
return $factory->make();
|
|
|
}
|
|
|
- } catch (Exception $e) {
|
|
|
+ } catch (Throwable $e) {
|
|
|
c::warn("Eloquent model factory failed to instantiate {$type}; trying to fetch from database.");
|
|
|
e::dumpExceptionIfVerbose($e, true);
|
|
|
|
|
|
$instance = new $type();
|
|
|
if ($instance instanceof \Illuminate\Database\Eloquent\Model) {
|
|
|
try {
|
|
|
- // we can't use a factory but can try to get one from the database
|
|
|
+ // We can't use a factory but can try to get one from the database
|
|
|
$firstInstance = $type::with($relations)->first();
|
|
|
if ($firstInstance) {
|
|
|
return $firstInstance;
|
|
|
}
|
|
|
- } catch (Exception $e) {
|
|
|
+ } catch (Throwable $e) {
|
|
|
// okay, we'll stick with `new`
|
|
|
c::warn("Failed to fetch first {$type} from database; using `new` to instantiate.");
|
|
|
e::dumpExceptionIfVerbose($e);
|