//Custom 403 errors
ErrorDocument 403 your-path/403.php
//Custom 404 errors
ErrorDocument 404 your-path/404.php
//Custom 500 errors
ErrorDocument 500 your-path/500.php
Please add an explanation of what the above has to do with the question asked. How does it relate to the requested .htaccess file?
Sorry, but such approach redirect user on error to related php page, I need to display an error on the go.
This is what you need. You can make these pages act exactly as you're asking - for eample they can all be symlinked to the same file which inspects the env vars (e.g. $_SERVER) to figure out which error to display.