View Source Protocol.UndefinedError exception (Elixir v1.16.2)

An exception raised when a protocol is not implemented for a given value.

The following fields of this exception are public and can be accessed freely:

  • :protocol (module/0) - the protocol that is not implemented
  • :value (term/0) - the value that does not implement the protocol

For example, this code:

Enum.at("A string!", 0)

would raise the following exception:

%Protocol.UndefinedError{
  protocol: Enumerable,
  value: "A string!",
  # ...
}