This might be of help: How to react to server rejecting client(reading the server error message client side)