Class 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
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer

        com.fasterxml.jackson.databind.JsonSerializer.None
    • Field Summary

      • Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

        _handledType
    • 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
      • Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer

        getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties
    • 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 class com.fasterxml.jackson.databind.ser.std.StdSerializer<Throwable>
        Parameters:
        value - The value to serialize
        gen - The JsonGenerator supplied by Jackson
        provider - The Jackson serialization provider
        Throws:
        IOException - if serialization fails, especially of the stack trace