I am writing a general Client-Server socket program where the client sends commands to the Server, which executes it and sends the result to the Client. 
However if there is an error while executing a command, I want to be able to inform the Client of an error. I know I could send the String "ERROR" or maybe something like -1 etc, but these could also be part of the command output. Is there any better way of sending an error or an exception over a socket.
My Server is in Java and Client is in Python
Typically when doing client-server communication you need to establish some kind of protocol.  One very simple protocol is to send the String "COMMAND" before you send any commands and the String "ERROR" before you send any errors.  This doubles the number of Strings you have to send but gives more flexibility.
There are also a number of more sophisticated protocols already developed.  Rather than sending Strings you could construct a Request object which you then serialize and send to the client.  The client can then reconstruct the Request object and perform the request whether it's performing an error or running a command.
Pass error on socket