What is the best practice to show an 404 page if a record is not found

When I create an own extension that is using its own records and try to display a details page for a deleted or non existing record there is an TargetNotFoundException. What is the best / suggested way to display the default 404 page in this case?

Hey Michael,

in TYPO3 v10 you have an ErrorController to use.
Full example (of ExtensionController showing extension detail in TER):

        'Extension not found!',
        ['code' => \TYPO3\CMS\Frontend\Page\PageAccessFailureReasons::INVALID_PAGE_ARGUMENTS]

I hope it helps after months. :wink: