Skip to content

Commit fc7610c

Browse files
committed
[Refactor] Improve exception message for missing request class
1 parent 1990af6 commit fc7610c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/Http/Requests/RequestResolver.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,24 @@ public function __invoke(string $resourceType, bool $allowNull = false): ?FormRe
9595
{
9696
$app = app();
9797

98-
try {
99-
$fqn = $this->custom($resourceType) ?: Str::replaceLast('Schema', $this->type, get_class(
100-
$app->make(SchemaContainer::class)->schemaFor($resourceType)
101-
));
102-
103-
if (!class_exists($fqn) && !$app->bound($fqn)) {
104-
if (true === $allowNull) {
105-
return null;
106-
} else if (isset(self::$defaults[$this->type])) {
107-
$fqn = self::$defaults[$this->type];
108-
}
98+
$fqn = $this->custom($resourceType) ?: Str::replaceLast('Schema', $this->type, get_class(
99+
$app->make(SchemaContainer::class)->schemaFor($resourceType)
100+
));
101+
102+
if (!class_exists($fqn) && !$app->bound($fqn)) {
103+
if (true === $allowNull) {
104+
return null;
105+
} else if (isset(self::$defaults[$this->type])) {
106+
$fqn = self::$defaults[$this->type];
109107
}
108+
}
110109

110+
try {
111111
return $app->make($fqn);
112112
} catch (BindingResolutionException $ex) {
113113
throw new LogicException(sprintf(
114-
'Unable to create request class of type [%s] for resource type %s.',
115-
$this->type,
114+
'Unable to create request class %s for resource type %s.',
115+
$fqn,
116116
$resourceType
117117
), 0, $ex);
118118
}

0 commit comments

Comments
 (0)