Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Drupal 7

Depending on where in the request:

return MENU_ACCESS_DENIED;
return MENU_NOT_FOUND;

or

return drupal_access_denied();
return drupal_not_found();

Drupal 8

use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

throw new AccessDeniedHttpException();
throw new NotFoundHttpException();
Impacts: 
Module developers