Ussd.ExceptionHandler behaviour (Ussd v0.2.0)

Copy Markdown View Source

Turns an exception raised while running a flow into a message the caller sees, instead of a dead session.

defmodule MyApp.UssdErrors do
  @behaviour Ussd.ExceptionHandler

  @impl Ussd.ExceptionHandler
  def handle(_exception), do: "Sorry, something went wrong. Please try again."
end

Wired in via Ussd.use_exception_handler/2, either as a module implementing this behaviour or as a 1-arity function.

Summary

Callbacks

Turns exception into the message the caller sees. The session always ends after this.

Callbacks

handle(t)

@callback handle(Exception.t()) :: String.t()

Turns exception into the message the caller sees. The session always ends after this.