Hi @MilanRapp,
There are multiple ways to do it.
First, you can implement it using ACS commons if you have installed it. You can refer to the below URL for the same.
https://adobe-consulting-services.github.io/acs-aem-commons/features/error-handler/index.html
Second, If you don't have ACS commons installed in your AEM instance, you can follow the below steps.
1. Go to '/apps/sling/servlet/errorhandler'
2 create 404.jsp, default.jsp in this directory and you can write the code to render content on the error page.