Display error message.

Method Signatures and Parameters

Jt.error(String body)

body (String)

The error text to display. Markdown is supported, see Jt#markdown(String) for more details.

Chainable builder methods

body(String body)

The error message content to display. Markdown is supported, see io.jeamlit.core.Jt#markdown(String) for more details.

icon(String icon)

An icon to display with the error message. The following values are valid:

  • A single-character emoji. For example: 🔥. Emoji short codes are not supported.
  • An icon from the Material Symbols library (rounded style) in the format :icon_name: where icon_name is the name of the icon in snake case. For example: :search:. See full list of icons here.
If null (default), no icon is displayed.

width(String width)

The width of the element. This can be one of the following:

  • stretch: The width of the element matches the width of the parent container.
  • An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container.

width(int widthPixels)

The width of the element in pixels. The element will have a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container.

key(String key)

A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key.

No description

use()

Put the widget in the app, in the MAIN container.

use(JtContainer container)

Put the widget in the app, in the provided container.

Examples

Simple error message

 import tech.catheu.jeamlit.core.Jt;

 public class ErrorApp {
     public static void main(String[] args) {
         String username = Jt.textInput("Username").use();

         if (username.isEmpty()) {
             Jt.error("Username is required!").use();
         } else if (username.length() < 3) {
             Jt.error("Username must be at least 3 characters long.").use();
         }
     }
 }

Error with markdown formatting

 import tech.catheu.jeamlit.core.Jt;

 public class FormattedErrorApp {
     public static void main(String[] args) {
         Jt.error("**Connection Failed**: Unable to connect to the database. Please check your settings.").use();
     }
 }

forum

Still have questions?

Go to our discussions forum for helpful information and advice from Jeamlit experts.