Added a method to send an error message to the client. Added Javadocs