Fix bug in error message helper [Fixes #81273874]