2

How can we handle custom errors in cakePHP?, For instance, if end user modify URL directly,

eg: http://localhost/cake/topics/view/6

in case if this value not available, how can we handle this type of situation. Code

if (!$this->Topic->exists($id)) 
  {
   //$this->cakeError('fatal_error');
   //$this->fatal_error('Invalid topic');
   //throw new NotFoundException(__('Invalid topic'));
    throw new NotFoundException(('Could not find that post'));
  }
  
  $options = array('conditions' => array('Topic.' . $this->Topic->primaryKey => $id));
  $this->set('topic', $this->Topic->find('first', $options));

just write

throw new NotFoundException(('Could not find that post'));

it is not good it seems. so how can we handle it ?

please help me

arjun
  • 51
  • 6

1 Answers1

0

A better way to just redirect it to 404 page .

You can do it with answers of questioned at: CakePHP 2.0 - How to make custom error pages?

Community
  • 1
  • 1
Root
  • 2,269
  • 5
  • 29
  • 58