Fixed an issue when printing error messages as JSON string from controllers.