Class ObfuscatedException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.ametys.plugins.core.ui.ObfuscatedException
All Implemented Interfaces:
Serializable

public class ObfuscatedException extends Exception
Wraps a throwable preventing access to it until reveal() is called. Before to being revealed, printing the exception will only result in a message providing a error reference. Once revealed, printing the exception will result in a message providing the error reference and the original exception. It is intended for case where an error report should be provided to a user. As it is not acceptable to provide stack trace directly. First print the obfuscated exception to the user, then reveal it and log the error.
See Also:
  • Constructor Details

    • ObfuscatedException

      protected ObfuscatedException(String reference, Throwable throwable)
      Construct an obfuscated exception with the given reference for the given exception
      Parameters:
      reference - the reference
      throwable - the throwable
  • Method Details

    • obfuscate

      public static ObfuscatedException obfuscate(Throwable throwable)
      Obfuscate an exception. A reference will be generated for the exception.
      Parameters:
      throwable - the throwable to obfuscate
      Returns:
      the obfuscated exception
    • getReference

      public String getReference()
      Get the reference of the obfuscated exception
      Returns:
      the reference
    • toString

      public String toString()
      Overrides:
      toString in class Throwable
    • obfuscate

      public void obfuscate()
      Obfuscate the original exception. After calling this, the original exception will be obfuscated until reveal() is called
    • reveal

      public void reveal()
      Stop obfuscating the original exception. After calling this, the original exception won't be obfuscated any more.
    • getCause

      public Throwable getCause()
      Overrides:
      getCause in class Throwable