Log in

Error Reporting in Forge

Error reporting in forge is implemented by the class ErrorViewer.

This class has an overloaded method for showing an error dialog:

public static void showError(Throwable ex);

public static void showError(Throwable ex, String format, Object... args);

public static void showError(Throwable ex, String message);


The only difference between the versions is how the error message is generated: The first version takes the message directly from Throwable.getMessage()

The second uses String.format() (better described at Formatter)

The third version uses the given string directly as the message.


Showing an error without Exception

In some cases, there may be no Exception for an error, for Example:

if(deckSize < 60) //show an error

If so, the preferred way to show the error is with a newly created exception:

showError(new Exception(), "Deck too small");

This way, the stack trace is still accessible