Package com.comphenix.protocol.error
Class DetailedErrorReporter
java.lang.Object
com.comphenix.protocol.error.DetailedErrorReporter
- All Implemented Interfaces:
ErrorReporter
Internal class used to handle exceptions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static booleanstatic final intstatic final Stringstatic final Stringprotected booleanstatic final Stringprotected AtomicIntegerprotected Loggerprotected intprotected Stringprotected WeakReference<org.bukkit.plugin.Plugin> protected Stringstatic final ReportTypeReport format for printing the current exception count.static final Stringprotected String -
Constructor Summary
ConstructorsConstructorDescriptionDetailedErrorReporter(org.bukkit.plugin.Plugin plugin) Create a default error reporting system.DetailedErrorReporter(org.bukkit.plugin.Plugin plugin, String prefix, String supportURL) Create a central error reporting system.DetailedErrorReporter(org.bukkit.plugin.Plugin plugin, String prefix, String supportURL, int maxErrorCount, Logger logger) Create a central error reporting system. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalParameter(String key, Object value) Adds the given global parameter.protected StringAdds the given prefix to every line in the text.protected booleanDetermine if we should print the given report.voidReset all global parameters.intRetrieve the current number of errors printed throughreportDetailed(Object, Report).getGlobalParameter(String key) Retrieve a global parameter by its key.Retrieve the current logger that is used to print all reports.intRetrieve the maximum number of errors we can print before we begin suppressing errors.Retrieve the prefix to apply to every line in the error reports.static StringgetStringDescription(Object value) Retrieve a string representation of the given object.Retrieve the support URL that will be added to all detailed reports.Retrieve a set of every registered global parameter.booleanDetermine if we're using detailed error reporting.protected static booleanisSimpleType(Object test) Determine if the given object is a wrapper for a primitive/simple type or not.voidreportDebug(Object sender, Report report) Prints a debug message from the current sender.voidreportDebug(Object sender, Report.ReportBuilder builder) Prints a debug message from the current sender.voidreportDetailed(Object sender, Report report) Prints a detailed error report about an unhandled exception.voidreportDetailed(Object sender, Report.ReportBuilder reportBuilder) Prints a detailed error report about an unhandled exception.voidreportMinimal(org.bukkit.plugin.Plugin sender, String methodName, Throwable error) Prints a small minimal error report regarding an exception from another plugin.voidreportMinimal(org.bukkit.plugin.Plugin sender, String methodName, Throwable error, Object... parameters) Prints a small minimal error report regarding an exception from another plugin.booleanreportMinimalNoSpam(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.voidreportWarning(Object sender, Report report) Prints a warning message from the current plugin.voidreportWarning(Object sender, Report.ReportBuilder reportBuilder) Prints a warning message from the current plugin.voidsetDetailedReporting(boolean detailedReporting) Set whether or not to use detailed error reporting.voidsetErrorCount(int errorCount) Set the number of errors printed.voidSet the current logger that is used to print all reports.voidsetMaxErrorCount(int maxErrorCount) Set the maximum number of errors we can print before we begin suppressing errors.voidSet the prefix to apply to every line in the error reports.voidsetSupportURL(String supportURL) Set the support URL that will be added to all detailed reports.
-
Field Details
-
REPORT_EXCEPTION_COUNT
Report format for printing the current exception count. -
SECOND_LEVEL_PREFIX
- See Also:
-
DEFAULT_PREFIX
- See Also:
-
DEFAULT_SUPPORT_URL
- See Also:
-
ERROR_PERMISSION
- See Also:
-
DEFAULT_MAX_ERROR_COUNT
public static final int DEFAULT_MAX_ERROR_COUNT- See Also:
-
prefix
-
supportURL
-
internalErrorCount
-
maxErrorCount
protected int maxErrorCount -
logger
-
pluginReference
-
pluginName
-
apacheCommonsMissing
protected static boolean apacheCommonsMissing -
detailedReporting
protected boolean detailedReporting -
globalParameters
-
-
Constructor Details
-
DetailedErrorReporter
public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin) Create a default error reporting system.- Parameters:
plugin- - the plugin owner.
-
DetailedErrorReporter
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:ErrorReporterPrints a small minimal error report regarding an exception from another plugin.- Specified by:
reportMinimalin interfaceErrorReporter- Parameters:
sender- - the other plugin.methodName- - name of the caller method.error- - the exception itself.parameters- - any relevant parameters to print.
-
reportMinimal
Description copied from interface:ErrorReporterPrints a small minimal error report regarding an exception from another plugin.- Specified by:
reportMinimalin interfaceErrorReporter- 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
Description copied from interface:ErrorReporterPrints a debug message from the current sender.- Specified by:
reportDebugin interfaceErrorReporter- Parameters:
sender- - the sender.builder- - the report builder.
-
reportDebug
Description copied from interface:ErrorReporterPrints a debug message from the current sender.Most users will not see this message.
- Specified by:
reportDebugin interfaceErrorReporter- Parameters:
sender- - the sender.report- - the report.
-
reportWarning
Description copied from interface:ErrorReporterPrints a warning message from the current plugin.- Specified by:
reportWarningin interfaceErrorReporter- Parameters:
sender- - the object containing the caller method.reportBuilder- - an error report builder that will be used to get the report.
-
reportWarning
Description copied from interface:ErrorReporterPrints a warning message from the current plugin.- Specified by:
reportWarningin interfaceErrorReporter- Parameters:
sender- - the object containing the caller method.report- - an error report to include.
-
canReport
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
Description copied from interface:ErrorReporterPrints a detailed error report about an unhandled exception.- Specified by:
reportDetailedin interfaceErrorReporter- Parameters:
sender- - the object containing the caller method.reportBuilder- - an error report builder that will be used to get the report.
-
reportDetailed
Description copied from interface:ErrorReporterPrints a detailed error report about an unhandled exception.- Specified by:
reportDetailedin interfaceErrorReporter- Parameters:
sender- - the object containing the caller method.report- - an error report to include.
-
addPrefix
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
Retrieve a string representation of the given object.- Parameters:
value- - object to convert.- Returns:
- String representation.
-
isSimpleType
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 throughreportDetailed(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
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
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
Retrieve a set of every registered global parameter.- Returns:
- Set of all registered global parameters.
-
getSupportURL
Retrieve the support URL that will be added to all detailed reports.- Returns:
- Support URL.
-
setSupportURL
Set the support URL that will be added to all detailed reports.- Parameters:
supportURL- - the new support URL.
-
getPrefix
Retrieve the prefix to apply to every line in the error reports.- Returns:
- Error report prefix.
-
setPrefix
Set the prefix to apply to every line in the error reports.- Parameters:
prefix- - new prefix.
-
getLogger
Retrieve the current logger that is used to print all reports.- Returns:
- The current logger.
-
setLogger
Set the current logger that is used to print all reports.- Parameters:
logger- - new logger.
-