send errors to the client as json