Skip to content

io7m-com/miscue

Repository files navigation

miscue

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.miscue

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

miscue

JavaFX component for displaying error dialogs.

Features

Usage

Given a structured error value:

SStructuredErrorType<String> error;

Create a new dialog and display it:

MSErrorDialogs.builder(error)
  .build()
  .showAndWait();

The contents of the dialog depends on the data present in the error value.

If only a message is present, the message will be displayed:

Message Only

If attributes are present, they will be displayed in a table below the message:

Attributes

If an exception is present, it will be displayed:

Exception

If a remediating action is present, it will be displayed:

Remediation

Any combination of the above is possible:

All

Reporting

If a reporting callback is provided to the builder, it will be evaluated when the user clicks the provided Report button. If no callback is provided, the Report button is disabled. The callback should be tied to your application's error reporting functionality.

MSErrorDialogs.builder(error)
  .setErrorReportCallback(() -> {
    LOG.debug("Pretending to send an error report...");
  })
  .build()
  .showAndWait();

CSS

All elements within an error dialog are assigned CSS classes:

CSS

A custom stylesheet can be specified to the dialog builder:

MSErrorDialogs.builder(error)
  .setCSS(URI.create("/path/to/custom.css"))
  .build()
  .showAndWait();

With great power comes great responsibility.

CSS Power

Demo

A demo application is included.