cakephp NotFoundException不显示任何内容

1)I wanna throw an error when id is not set or id is wrong. 2)I wanna throw an error when id is set but is not in the database. Why don't show me anything when i put wrong id? I expected to display the error message.

ItemController.php:

<?php
/**
 * Created by PhpStorm.
 * User: Marian39
 * Date: 11/17/2016
 * Time: 8:07 PM
 */

namespace App\Controller;

use Cake\Network\Exception\NotFoundException;
use Cake\Datasource\Exception\RecordNotFoundException;

class ItemsController extends AppController
{
    public function view($id = null)
    {
        if(!$id)
        {
            throw new NotFoundException(__("id is not set or wrong"));
        }

        $data= $this->Items->findById($id);

        $display = $this->Items->get($id);



 try {
            $display= $this->Items->get($id);
     } 
catch (RecordNotFoundException $e) {
    //no code need
            }


        $this->set('items', $data);

        $this->set('error', $display);
    }

    public function index()
    {
        $data = $this->Items->find('all', array('order'=>'year'));
        $count = $this->Items->find()->count();
        $info = array('items'=>$data,
                      'count' => $count);
        $this->set($info);
         // $this->set('items', $data);
        // $this->set('count', $count);

        //this->set('color', 'blue');
    }

}
?>

view.ctp from template:

<?php foreach($items as $item): ?>

<div>
    <h2>
        <?php echo h($item['title']);?>
        <?php echo h($item['year']);?>
    </h2>
    <p>
        Length: <?php echo h($item['length']);?>
    </p>
    <div>
        <?php echo h($item['description']);?>
    </div>
</div>

<?php endforeach; ?>

For enhanced exception handling, you should use get() instead of findById().

If the get operation does not find any results a Cake\Datasource\Exception\RecordNotFoundException will be raised.

You can either catch this exception yourself, or allow CakePHP to convert it into a 404 error.

In order to check if it's a valid record, you need to mention this on top:

namespace App\Controller;

use Cake\Network\Exception\NotFoundException;
use Cake\Datasource\Exception\RecordNotFoundException;

public function view($id = null)
{
    /* Other code*/
    try {
        $data= $this->Items->get($id);
    } catch (RecordNotFoundException $e) {
        // Show appropriate user-friendly message
    }
}