We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
one
1 parent 14f465f commit a655295Copy full SHA for a655295
1 file changed
src/resources/ElementResource.php
@@ -17,6 +17,7 @@
17
use yii\base\BaseObject;
18
use yii\base\Exception;
19
use yii\base\InvalidConfigException;
20
+use yii\web\NotFoundHttpException;
21
22
/**
23
* Element resource adapter class.
@@ -118,6 +119,10 @@ public function getResource(): ResourceInterface
118
119
if ($this->one) {
120
$element = $query->one();
121
122
+ if (!$element) {
123
+ throw new NotFoundHttpException('No element exists that matches the endpoint criteria');
124
+ }
125
+
126
$resource = new Item($element, $transformer, $this->resourceKey);
127
} else if ($this->paginate) {
128
// Create the paginator
0 commit comments