getSelfURL(); if ($reason === null) { parent::__construct([ErrorCodes::NOTFOUND, '%URL%' => $url], null, 404); $this->message = "The requested page '$url' could not be found."; } else { parent::__construct([ErrorCodes::NOTFOUNDREASON, '%URL%' => $url, '%REASON%' => $reason], null, 404); $this->message = "The requested page '$url' could not be found. " . $reason; } } /** * Retrieve the reason why the given page could not be found. * * @return string|null The reason why the page could not be found. */ public function getReason(): ?string { return $this->reason; } /** * NotFound exceptions don't need to display a backtrace, as they are very simple and the trace is usually trivial, * so just log the message without any backtrace at all. * * @param bool $anonymize Whether to anonymize the trace or not. * * @return string[] */ public function format(bool $anonymize = false): array { return [ $this->getClass() . ': ' . $this->getMessage(), ]; } }