Add 404 response to REST response for invalid note ID (https://github.com/woocommerce/woocommerce-admin/pull/1194)
This commit is contained in:
parent
a0f23c93c9
commit
e0596ea249
|
@ -76,6 +76,15 @@ class WC_Admin_REST_Admin_Notes_Controller extends WC_REST_CRUD_Controller {
|
|||
*/
|
||||
public function get_item( $request ) {
|
||||
$note = WC_Admin_Notes::get_note( $request->get_param( 'id' ) );
|
||||
|
||||
if ( ! $note ) {
|
||||
return new WP_Error(
|
||||
'woocommerce_admin_notes_invalid_id',
|
||||
__( 'Sorry, there is no resouce with that ID.', 'wc-admin' ),
|
||||
array( 'status' => 404 )
|
||||
);
|
||||
}
|
||||
|
||||
if ( is_wp_error( $note ) ) {
|
||||
return $note;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue