A number of answers have pointed out that it's not best practice to display these errors. However, I'm going to focus on your question: is it safe?
Lets have a look at an example error message. This app is written in Python and Flask:
This tells us a few things about the application: it's using SQLite, the app is in
c:\jobs\token\, there's a table
data and a few other things.
There is no user data here. It doesn't reveal another person's account balance, private messages, anything like that. While it's possible an error message could reveal that, in practice that is rare.
So how confidential are the application details? The main concern here is making life easier for an attacker. Certain vulnerabilities, such as path traversal and SQL injection are easier to exploit with a bit of information leakage in the error messages. However, they are still exploitable without the information leak - it's just harder work. Restricting error messages does not stop these attacks. It only makes exploitation slightly harder. The change is so minor I don't even consider it when I'm assessing the risk of a vulnerability like SQL injection.
So, the answer to your question is yes, it is safe. It's not best practice, but in no way is it particularly unsafe.