Class BeanRuntimeException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.juneau.commons.reflect.BeanRuntimeException
All Implemented Interfaces:
Serializable

A RuntimeException wrapper around common reflection exceptions.

This exception is used to wrap checked exceptions that commonly occur when using Java reflection APIs, converting them into unchecked exceptions for easier handling in bean-processing code.

Wrapped Exceptions:

The exception message can optionally include the class name of the bean that caused the exception, making it easier to identify the source of reflection errors in complex bean hierarchies.

Example:

try { Constructor<?> c = MyBean.class.getConstructor(); c.newInstance(); } catch (Exception e) { throw new BeanRuntimeException(e, MyBean.class, "Failed to instantiate bean"); }

See Also:
  • Constructor Details

    • BeanRuntimeException

      public BeanRuntimeException(Class<?> c, String message, Object... args)
      Constructor.
      Parameters:
      c - The class name of the bean that caused the exception.
      message - The error message.
      args - Arguments passed in to the String.format() method.
    • BeanRuntimeException

      public BeanRuntimeException(String message)
      Constructor.
      Parameters:
      message - The error message.
    • BeanRuntimeException

      public BeanRuntimeException(String message, Object... args)
      Constructor.
      Parameters:
      message - The error message.
      args - Arguments passed in to the String.format() method.
    • BeanRuntimeException

      Constructor.
      Parameters:
      cause - The initial cause of the exception.
    • BeanRuntimeException

      public BeanRuntimeException(Throwable cause, Class<?> c, String message, Object... args)
      Constructor.
      Parameters:
      cause - The cause of this exception.
      c - The class name of the bean that caused the exception.
      message - The MessageFormat-style message.
      args - Optional MessageFormat-style arguments.