Class ThrowableSerializer
- java.lang.Object
-
- com.fasterxml.jackson.databind.JsonSerializer<T>
-
- com.fasterxml.jackson.databind.ser.std.StdSerializer<Throwable>
-
- com.identityworksllc.iiq.common.vo.ThrowableSerializer
-
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable
,com.fasterxml.jackson.databind.jsonschema.SchemaAware
,Serializable
public class ThrowableSerializer extends com.fasterxml.jackson.databind.ser.std.StdSerializer<Throwable>
A custom Jackson serializer for transforming a Throwable into a standard Map format, including type, message, and stack trace.This is primarily intended for REST API usage.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ThrowableSerializer()
Constructs a new StampedMessageSerializerThrowableSerializer(Class<Throwable> t)
Constructs a new serializer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
serialize(Throwable value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider provider)
Serializes the given Throwable object, if not null, into a map containing a string type (the class name), the string message, and a stack trace.-
Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
_neitherNull, _nonEmpty, acceptJsonFormatVisitor, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
-
-
-
-
Constructor Detail
-
ThrowableSerializer
public ThrowableSerializer()
Constructs a new StampedMessageSerializer
-
ThrowableSerializer
public ThrowableSerializer(Class<Throwable> t)
Constructs a new serializer- Parameters:
t
- The input type
-
-
Method Detail
-
serialize
public void serialize(Throwable value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider provider) throws IOException
Serializes the given Throwable object, if not null, into a map containing a string type (the class name), the string message, and a stack trace.- Specified by:
serialize
in classcom.fasterxml.jackson.databind.ser.std.StdSerializer<Throwable>
- Parameters:
value
- The value to serializegen
- The JsonGenerator supplied by Jacksonprovider
- The Jackson serialization provider- Throws:
IOException
- if serialization fails, especially of the stack trace
-
-