Package limn.io

Class MalformedContentException

All Implemented Interfaces:
Serializable

public final class MalformedContentException extends RuntimeException
What a file, a resource or a block of bytes is refused with when what it holds is not what its format says: a picture, a sound, a video, a font, a model, a theme, cut short or wrong in any way. It is the one exception an application that opens a user's file catches to tell the user the file is broken.

It is not what a file that cannot be read arrives as, which is an I/O failure (IOException or UncheckedIOException); nor a format nothing here decodes, which is an UnsupportedOperationException; nor a wrong argument of the caller's own, which stays an IllegalArgumentException. Its message says what is wrong, in words for a log.

See Also:
  • Constructor Details

    • MalformedContentException

      public MalformedContentException(String format, String message)
      Parameters:
      format - the format's name as a person writes it, "glTF", "PNG"
      message - what is wrong with the content
    • MalformedContentException

      public MalformedContentException(String format, String message, @Nullable Throwable cause)
      Parameters:
      format - the format's name
      message - what is wrong with the content
      cause - what a decoder underneath said, or null
    • MalformedContentException

      public MalformedContentException(String format, String message, long position, @Nullable Throwable cause)
      Parameters:
      format - the format's name
      message - what is wrong with the content
      position - where: a line of a text, counted from 1, or an offset into the bytes, counted from 0, as the format's reader documents; -1 for unknown
      cause - what a decoder underneath said, or null
  • Method Details

    • format

      public String format()
      Returns:
      the name of the format the content was read as
    • position

      public long position()
      Returns:
      the line or the offset the reader stopped at, or -1 where it knows none