refactored error message apis