Skip to content

Commit 41bd459

Browse files
author
Branislav Bujisic
committed
Replace RestfulUnprocessableEntityException with RestfulNotFoundException if entity cannot be loaded.
1 parent 16ec9b9 commit 41bd459

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

plugins/restful/RestfulEntityBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ protected function isValidEntity($op, $entity_id) {
11621162
);
11631163

11641164
if (!$entity = entity_load_single($entity_type, $entity_id)) {
1165-
throw new RestfulUnprocessableEntityException(format_string('The entity ID @id for @resource does not exist.', $params));
1165+
throw new RestfulNotFoundException(format_string('The entity ID @id for @resource does not exist.', $params));
11661166
}
11671167

11681168
list(,, $bundle) = entity_extract_ids($entity_type, $entity);

tests/RestfulExceptionHandleTestCase.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class RestfulExceptionHandleTestCase extends RestfulCurlBaseTestCase {
4545
$url = 'api/v1.0/articles/1';
4646
$result = $this->httpRequest($url);
4747
$body = drupal_json_decode($result['body']);
48-
$this->assertEqual($result['code'], '422', format_string('422 status code sent for @url url.', array('@url' => $url)));
48+
$this->assertEqual($result['code'], '404', format_string('404 status code sent for @url url.', array('@url' => $url)));
4949
$this->assertTrue(strpos($result['headers'], 'application/problem+json;'), '"application/problem+json" found in invalid request.');
5050
$this->assertEqual($body['title'], 'The entity ID 1 for Articles does not exist.', 'Correct error message.');
5151
}

0 commit comments

Comments
 (0)