@Override
    public byte[] serialize(T data) {
        try {
            byte[] result = serializeInternal(data);
            // reset error state after serialize success
            errorOccurred = false;
            return result;
        } catch (Exception e) {
            errorOccurred = true;
            if (formatMetricGroup != null) {
                formatMetricGroup.getNumRecordsSerializeError().inc(1L);
            }
            if (ignoreErrors) {
                if (formatMetricGroup != null) {
                    formatMetricGroup.getNumRecordsSerializeErrorIgnored().inc(1L);
                }
                LOG.warn("Could not properly serialize the data {}", data, e);
                return null;
            }
            throw new RuntimeException("Failed to serialize data " + data, e);
        }
    }
Serialize the data and handle the failure.

<p>Note: Returns null if the message could not be properly serialized.
inlong-sort/sort-formats/format-rowdata/format-rowdata-base/src/main/java/org/apache/inlong/sort/formats/base/DefaultSerializationSchema.java