private void sendErrorPacket( Packet packet, PacketError.Condition error, String message )
    {
        if (packet.getError() != null) {
            Log.debug("Avoid generating an error in response to a stanza that itself has an error (to avoid the chance of entering an endless back-and-forth of exchanging errors). Suppress sending an {} error (with message '{}') in response to: {}", error, message, packet);
            return;
        }
        if ( packet instanceof IQ )
        {
            IQ reply = IQ.createResultIQ((IQ) packet);
            reply.setChildElement(((IQ) packet).getChildElement().createCopy());
            reply.setError(error);
            if ( message != null )
            {
                reply.getError().setText(message);
            }
            XMPPServer.getInstance().getPacketRouter().route(reply);
        }
        else
        {
            Packet reply = packet.createCopy();
            reply.setError(error);
            if ( message != null )
            {
                reply.getError().setText(message);
            }
            reply.setFrom(packet.getTo());
            reply.setTo(packet.getFrom());
            XMPPServer.getInstance().getPacketRouter().route(reply);
        }
    }
Generate and send an error packet to indicate that something went wrong.

@param packet  the packet to be responded to with an error.
@param error   the reason why the operation failed.
@param message an optional human-readable error message.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/MultiUserChatServiceImpl.java