Refacotring error messages to use javascript.