Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.ser.impl;
 
 
 
Special bogus "serializer" that will throw com.fasterxml.jackson.core.JsonGenerationException if its serialize(java.lang.Object,com.fasterxml.jackson.core.JsonGenerator,com.fasterxml.jackson.databind.SerializerProvider) gets invoked. Most commonly registered as handler for unknown types, as well as for catching unintended usage (like trying to use null as Map/Object key).
public final class FailingSerializer
    extends StdSerializer<Object>
    final String _msg;
    
    public FailingSerializer(String msg) {
        super(Object.class);
         = msg;
    }
    
    @Override
    public void serialize(Object valueJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        throw new JsonGenerationException();
    }
    @Override
    public JsonNode getSchema(SerializerProvider providerType typeHint)
        throws JsonMappingException
    {
        return null;
    }
    
    @Override
    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitorJavaType typeHint)
    {
        ;
    }
New to GrepCode? Check out our FAQ X