Class DetailedErrorReporter

java.lang.Object
com.comphenix.protocol.error.DetailedErrorReporter
All Implemented Interfaces:
ErrorReporter

public class DetailedErrorReporter extends Object implements ErrorReporter
Internal class used to handle exceptions.
  • Field Details

    • REPORT_EXCEPTION_COUNT

      public static final ReportType REPORT_EXCEPTION_COUNT
      Report format for printing the current exception count.
    • SECOND_LEVEL_PREFIX

      public static final String SECOND_LEVEL_PREFIX
      See Also:
    • DEFAULT_PREFIX

      public static final String DEFAULT_PREFIX
      See Also:
    • DEFAULT_SUPPORT_URL

      public static final String DEFAULT_SUPPORT_URL
      See Also:
    • ERROR_PERMISSION

      public static final String ERROR_PERMISSION
      See Also:
    • DEFAULT_MAX_ERROR_COUNT

      public static final int DEFAULT_MAX_ERROR_COUNT
      See Also:
    • prefix

      protected String prefix
    • supportURL

      protected String supportURL
    • internalErrorCount

      protected AtomicInteger internalErrorCount
    • maxErrorCount

      protected int maxErrorCount
    • logger

      protected Logger logger
    • pluginReference

      protected WeakReference<org.bukkit.plugin.Plugin> pluginReference
    • pluginName

      protected String pluginName
    • apacheCommonsMissing

      protected static boolean apacheCommonsMissing
    • detailedReporting

      protected boolean detailedReporting
    • globalParameters

      protected Map<String,Object> globalParameters
  • Constructor Details

    • DetailedErrorReporter

      public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin)
      Create a default error reporting system.
      Parameters:
      plugin - - the plugin owner.
    • DetailedErrorReporter

      public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin, String prefix, String supportURL)
      Create a central error reporting system.
      Parameters:
      plugin - - the plugin owner.
      prefix - - default line prefix.
      supportURL - - URL to report the error.
    • DetailedErrorReporter

      public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin, String prefix, String supportURL, int maxErrorCount, Logger logger)
      Create a central error reporting system.
      Parameters:
      plugin - - the plugin owner.
      prefix - - default line prefix.
      supportURL - - URL to report the error.
      maxErrorCount - - number of errors to print before giving up.
      logger - - current logger.
  • Method Details

    • isDetailedReporting

      public boolean isDetailedReporting()
      Determine if we're using detailed error reporting.
      Returns:
      TRUE if we are, FALSE otherwise.
    • setDetailedReporting

      public void setDetailedReporting(boolean detailedReporting)
      Set whether or not to use detailed error reporting.
      Parameters:
      detailedReporting - - TRUE to enable it, FALSE otherwise.
    • reportMinimal

      public void reportMinimal(org.bukkit.plugin.Plugin sender, String methodName, Throwable error, Object... parameters)
      Description copied from interface: ErrorReporter
      Prints a small minimal error report regarding an exception from another plugin.
      Specified by:
      reportMinimal in interface ErrorReporter
      Parameters:
      sender - - the other plugin.
      methodName - - name of the caller method.
      error - - the exception itself.
      parameters - - any relevant parameters to print.
    • reportMinimal

      public void reportMinimal(org.bukkit.plugin.Plugin sender, String methodName, Throwable error)
      Description copied from interface: ErrorReporter
      Prints a small minimal error report regarding an exception from another plugin.
      Specified by:
      reportMinimal in interface ErrorReporter
      Parameters:
      sender - - the other plugin.
      methodName - - name of the caller method.
      error - - the exception itself.
    • reportMinimalNoSpam

      public boolean reportMinimalNoSpam(org.bukkit.plugin.Plugin sender, String methodName, Throwable error)
      Report a problem with a given method and plugin, ensuring that we don't exceed the maximum number of error reports.
      Parameters:
      sender - - the component that observed this exception.
      methodName - - the method name.
      error - - the error itself.
      Returns:
      TRUE if the error was printed, FALSE if it was suppressed.
    • reportDebug

      public void reportDebug(Object sender, Report.ReportBuilder builder)
      Description copied from interface: ErrorReporter
      Prints a debug message from the current sender.
      Specified by:
      reportDebug in interface ErrorReporter
      Parameters:
      sender - - the sender.
      builder - - the report builder.
    • reportDebug

      public void reportDebug(Object sender, Report report)
      Description copied from interface: ErrorReporter
      Prints a debug message from the current sender.

      Most users will not see this message.

      Specified by:
      reportDebug in interface ErrorReporter
      Parameters:
      sender - - the sender.
      report - - the report.
    • reportWarning

      public void reportWarning(Object sender, Report.ReportBuilder reportBuilder)
      Description copied from interface: ErrorReporter
      Prints a warning message from the current plugin.
      Specified by:
      reportWarning in interface ErrorReporter
      Parameters:
      sender - - the object containing the caller method.
      reportBuilder - - an error report builder that will be used to get the report.
    • reportWarning

      public void reportWarning(Object sender, Report report)
      Description copied from interface: ErrorReporter
      Prints a warning message from the current plugin.
      Specified by:
      reportWarning in interface ErrorReporter
      Parameters:
      sender - - the object containing the caller method.
      report - - an error report to include.
    • canReport

      protected boolean canReport(Report report)
      Determine if we should print the given report.

      The default implementation will check for rate limits.

      Parameters:
      report - - the report to check.
      Returns:
      TRUE if we should print it, FALSE otherwise.
    • reportDetailed

      public void reportDetailed(Object sender, Report.ReportBuilder reportBuilder)
      Description copied from interface: ErrorReporter
      Prints a detailed error report about an unhandled exception.
      Specified by:
      reportDetailed in interface ErrorReporter
      Parameters:
      sender - - the object containing the caller method.
      reportBuilder - - an error report builder that will be used to get the report.
    • reportDetailed

      public void reportDetailed(Object sender, Report report)
      Description copied from interface: ErrorReporter
      Prints a detailed error report about an unhandled exception.
      Specified by:
      reportDetailed in interface ErrorReporter
      Parameters:
      sender - - the object containing the caller method.
      report - - an error report to include.
    • addPrefix

      protected String addPrefix(String text, String prefix)
      Adds the given prefix to every line in the text.
      Parameters:
      text - - text to modify.
      prefix - - prefix added to every line in the text.
      Returns:
      The modified text.
    • getStringDescription

      public static String getStringDescription(Object value)
      Retrieve a string representation of the given object.
      Parameters:
      value - - object to convert.
      Returns:
      String representation.
    • isSimpleType

      protected static boolean isSimpleType(Object test)
      Determine if the given object is a wrapper for a primitive/simple type or not.
      Parameters:
      test - - the object to test.
      Returns:
      TRUE if this object is simple enough to simply be printed, FALSE othewise.
    • getErrorCount

      public int getErrorCount()
      Retrieve the current number of errors printed through reportDetailed(Object, Report).
      Returns:
      Number of errors printed.
    • setErrorCount

      public void setErrorCount(int errorCount)
      Set the number of errors printed.
      Parameters:
      errorCount - - new number of errors printed.
    • getMaxErrorCount

      public int getMaxErrorCount()
      Retrieve the maximum number of errors we can print before we begin suppressing errors.
      Returns:
      Maximum number of errors.
    • setMaxErrorCount

      public void setMaxErrorCount(int maxErrorCount)
      Set the maximum number of errors we can print before we begin suppressing errors.
      Parameters:
      maxErrorCount - - new max count.
    • addGlobalParameter

      public void addGlobalParameter(String key, Object value)
      Adds the given global parameter. It will be included in every error report.

      Both key and value must be non-null.

      Parameters:
      key - - name of parameter.
      value - - the global parameter itself.
    • getGlobalParameter

      public Object getGlobalParameter(String key)
      Retrieve a global parameter by its key.
      Parameters:
      key - - key of the parameter to retrieve.
      Returns:
      The value of the global parameter, or NULL if not found.
    • clearGlobalParameters

      public void clearGlobalParameters()
      Reset all global parameters.
    • globalParameters

      public Set<String> globalParameters()
      Retrieve a set of every registered global parameter.
      Returns:
      Set of all registered global parameters.
    • getSupportURL

      public String getSupportURL()
      Retrieve the support URL that will be added to all detailed reports.
      Returns:
      Support URL.
    • setSupportURL

      public void setSupportURL(String supportURL)
      Set the support URL that will be added to all detailed reports.
      Parameters:
      supportURL - - the new support URL.
    • getPrefix

      public String getPrefix()
      Retrieve the prefix to apply to every line in the error reports.
      Returns:
      Error report prefix.
    • setPrefix

      public void setPrefix(String prefix)
      Set the prefix to apply to every line in the error reports.
      Parameters:
      prefix - - new prefix.
    • getLogger

      public Logger getLogger()
      Retrieve the current logger that is used to print all reports.
      Returns:
      The current logger.
    • setLogger

      public void setLogger(Logger logger)
      Set the current logger that is used to print all reports.
      Parameters:
      logger - - new logger.