Class Exceptions

java.lang.Object
org.apache.groovy.json.internal.Exceptions

public class Exceptions extends Object
Internal exception helpers used by the JSON parser implementation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Runtime exception used inside the JSON internals to simplify propagation.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    die()
    Throws a generic internal JSON exception.
    static <T> T
    die(Class<T> clazz, String message)
    Throws an internal JSON exception with the supplied message.
    static boolean
    die(String message)
    Throws an internal JSON exception with the supplied message.
    static <T> T
    handle(Class<T> clazz, Exception e)
    Rethrows the supplied exception as an internal JSON exception.
    static <T> T
    handle(Class<T> clazz, String message, Throwable e)
    Rethrows the supplied throwable as an internal JSON exception with a message.
    static void
    Rethrows the supplied exception as an internal JSON exception.
    static void
    handle(String message, Throwable e)
    Rethrows the supplied throwable as an internal JSON exception with a message.
    static String
    sputs(Object... messages)
    Creates a temporary buffer, appends the supplied messages, and returns the result.
    static String
    sputs(CharBuf buf, Object... messages)
    Appends messages to the supplied buffer and returns its current contents.
    static String
    Formats an exception and its stack trace for debug output.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Exceptions

      public Exceptions()
  • Method Details

    • die

      public static boolean die()
      Throws a generic internal JSON exception.
      Returns:
      never returns normally
    • die

      public static boolean die(String message)
      Throws an internal JSON exception with the supplied message.
      Parameters:
      message - the failure message
      Returns:
      never returns normally
    • die

      public static <T> T die(Class<T> clazz, String message)
      Throws an internal JSON exception with the supplied message.
      Type Parameters:
      T - the generic return type
      Parameters:
      clazz - the ignored target type used for generic flow
      message - the failure message
      Returns:
      never returns normally
    • handle

      public static void handle(Exception e)
      Rethrows the supplied exception as an internal JSON exception.
      Parameters:
      e - the exception to wrap
    • handle

      public static <T> T handle(Class<T> clazz, Exception e)
      Rethrows the supplied exception as an internal JSON exception.
      Type Parameters:
      T - the generic return type
      Parameters:
      clazz - the ignored target type used for generic flow
      e - the exception to wrap
      Returns:
      never returns normally
    • handle

      public static <T> T handle(Class<T> clazz, String message, Throwable e)
      Rethrows the supplied throwable as an internal JSON exception with a message.
      Type Parameters:
      T - the generic return type
      Parameters:
      clazz - the ignored target type used for generic flow
      message - the failure message
      e - the throwable to wrap
      Returns:
      never returns normally
    • handle

      public static void handle(String message, Throwable e)
      Rethrows the supplied throwable as an internal JSON exception with a message.
      Parameters:
      message - the failure message
      e - the throwable to wrap
    • toString

      public static String toString(Exception ex)
      Formats an exception and its stack trace for debug output.
      Parameters:
      ex - the exception to format
      Returns:
      the formatted exception text
    • sputs

      public static String sputs(CharBuf buf, Object... messages)
      Appends messages to the supplied buffer and returns its current contents.
      Parameters:
      buf - the destination buffer
      messages - the messages to append
      Returns:
      the buffer content after appending the messages
    • sputs

      public static String sputs(Object... messages)
      Creates a temporary buffer, appends the supplied messages, and returns the result.
      Parameters:
      messages - the messages to append
      Returns:
      the formatted message text