View Source Tux.Alertable protocol (Tux v0.4.0)

Alertable protocol is used by Tux.Show to display command error results in a user-friendly fashion using the Tux.Alert struct.

The protocol is implemented for the following types:

  • Strings – alertable is implemented for strings, so that if you return {:error, "some message"} from a command, the message will be shown as a Tux.Alert.

  • Tux.Error - alertable is also implemented for the Tux.Error struct or any struct which is constructed with use Tux.Error, so that if you return {:error, %Tux.Error{}} or {:error, %MyDerivedError{}} from a command, the struct will be shown as a Tux.Alert.

  • Exceptions - alertable is implemented for the Elixir Exception structs and will extract the :message field as the alert's title. Thus, if your app throws an exception and the dispatcher is using the options rescue: true, the thrown exception will be shown as an alert.

Summary

Types

t()

All the types that implement this protocol.

Functions

The detailed message of the alert

The title of the alert

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

message(term)

The detailed message of the alert

title(term)

The title of the alert