Class ErrorReport<T extends Throwable>
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.ErrorReport<T>
- Type Parameters:
T- The type ofThrowablewhich has spawned thisErrorReport
This class represents an
ErrorReport.
Error reports are thrown when a BlockTicker is causing problems.
To ensure that the console doesn't get too spammy, we destroy the block and generate
an ErrorReport instead.
Error reports get saved in the plugin folder.- Author:
- TheBusyBiscuit
-
Constructor Summary
ConstructorsConstructorDescriptionErrorReport(T throwable, SlimefunItem item) This constructs a newErrorReportfor the givenSlimefunItem.ErrorReport(T throwable, SlimefunAddon addon, Consumer<PrintStream> printer) This is the base constructor for anErrorReport.ErrorReport(T throwable, Location l, SlimefunItem item) -
Method Summary
Modifier and TypeMethodDescriptionstatic intcount()This method returns the amount ofErrorReportscreated in this session.getFile()This method returns theFilethisErrorReporthas been written to.This returns theThrowablethat was thrown.static voidThis helper method wraps the givenRunnableinto a try-catch block.
-
Constructor Details
-
ErrorReport
@ParametersAreNonnullByDefault public ErrorReport(T throwable, SlimefunAddon addon, Consumer<PrintStream> printer) This is the base constructor for anErrorReport. It will only print the necessary info and provides aConsumerfor any more detailed needs.- Parameters:
throwable- TheThrowablewhich caused thisErrorReport.addon- TheSlimefunAddonresponsible.printer- A customConsumerto add more details.
-
ErrorReport
- Parameters:
throwable- TheThrowablewhich caused thisErrorReport.l- TheLocationat which the error was thrown.item- TheSlimefunItemresponsible.
-
ErrorReport
This constructs a newErrorReportfor the givenSlimefunItem.- Parameters:
throwable- TheThrowablewhich caused thisErrorReport.item- TheSlimefunItemresponsible.
-
-
Method Details
-
getFile
This method returns theFilethisErrorReporthas been written to.- Returns:
- The
Filefor thisErrorReport
-
getThrown
This returns theThrowablethat was thrown.- Returns:
- The
Throwable
-
count
public static int count()This method returns the amount ofErrorReportscreated in this session.- Returns:
- The amount of
ErrorReportscreated.
-
tryCatch
public static void tryCatch(@Nonnull Function<Exception, ErrorReport<Exception>> function, @Nonnull Runnable runnable) This helper method wraps the givenRunnableinto a try-catch block. When anExceptionoccurs, a newErrorReportwill be generated using the providedFunction.- Parameters:
function- TheFunctionto generate a newErrorReportrunnable- The code to execute
-