Class ErrorReport<T extends Throwable>
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.ErrorReport<T>
- Type Parameters:
T
- The type ofThrowable
which 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
ConstructorDescriptionErrorReport
(T throwable, SlimefunItem item) This constructs a newErrorReport
for 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 int
count()
This method returns the amount ofErrorReports
created in this session.getFile()
This method returns theFile
thisErrorReport
has been written to.This returns theThrowable
that was thrown.static void
This helper method wraps the givenRunnable
into 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 aConsumer
for any more detailed needs.- Parameters:
throwable
- TheThrowable
which caused thisErrorReport
.addon
- TheSlimefunAddon
responsible.printer
- A customConsumer
to add more details.
-
ErrorReport
- Parameters:
throwable
- TheThrowable
which caused thisErrorReport
.l
- TheLocation
at which the error was thrown.item
- TheSlimefunItem
responsible.
-
ErrorReport
This constructs a newErrorReport
for the givenSlimefunItem
.- Parameters:
throwable
- TheThrowable
which caused thisErrorReport
.item
- TheSlimefunItem
responsible.
-
-
Method Details
-
getFile
This method returns theFile
thisErrorReport
has been written to.- Returns:
- The
File
for thisErrorReport
-
getThrown
This returns theThrowable
that was thrown.- Returns:
- The
Throwable
-
count
public static int count()This method returns the amount ofErrorReports
created in this session.- Returns:
- The amount of
ErrorReports
created.
-
tryCatch
public static void tryCatch(@Nonnull Function<Exception, ErrorReport<Exception>> function, @Nonnull Runnable runnable) This helper method wraps the givenRunnable
into a try-catch block. When anException
occurs, a newErrorReport
will be generated using the providedFunction
.- Parameters:
function
- TheFunction
to generate a newErrorReport
runnable
- The code to execute
-