public Object callMethod(String method, List<Object> params) throws InvalidResponseException, ConnectionLostException {
        try {
            return client.execute(method, params);
        } catch (XmlRpcException xe) {
            switch (xe.code) {
                //Non-fatal exception
                case 1: throw new InvalidResponseException("Aria2 Error", xe);

                //Connection lost exception
                case 0: throw new ConnectionLostException("Lost connection to Aria2", xe);

                //Unknown code
                default: throw new ConnectionLostException("Server error code ["+xe.code+"]", xe);
            }
        } catch (Exception e) {
        	throw new ConnectionLostException("Cannot execute command", e);
        }
    }