Trogon.Error.MetadataValue (Trogon.Error v0.4.0)

View Source

Represents a metadata entry with both value and visibility level.

Each metadata entry in a Trogon error contains not just the value, but also its visibility level which determines who can see this metadata.

Visibility Levels

  • :INTERNAL - Only visible to internal systems and developers (default)
  • :PRIVATE - Visible to authenticated users but not public
  • :PUBLIC - Visible to everyone including end users

Examples

iex> Trogon.Error.MetadataValue.new("secret data", :PRIVATE)
%Trogon.Error.MetadataValue{value: "secret data", visibility: :PRIVATE}

iex> Trogon.Error.MetadataValue.new(123)
%Trogon.Error.MetadataValue{value: "123", visibility: :INTERNAL}

Summary

Functions

Creates a new MetadataValue with the given value and default visibility.

Creates a new MetadataValue with the given value and visibility.

Types

t()

@type t() :: %Trogon.Error.MetadataValue{value: String.t(), visibility: visibility()}

visibility()

@type visibility() :: :INTERNAL | :PRIVATE | :PUBLIC

Functions

new(value)

@spec new(term()) :: t()

Creates a new MetadataValue with the given value and default visibility.

Examples

iex> Trogon.Error.MetadataValue.new("secret")
%Trogon.Error.MetadataValue{value: "secret", visibility: :INTERNAL}

new(value, visibility)

@spec new(term(), visibility()) :: t()

Creates a new MetadataValue with the given value and visibility.

The value will be converted to a string if it's not already one.

Examples

iex> Trogon.Error.MetadataValue.new("secret", :PRIVATE)
%Trogon.Error.MetadataValue{value: "secret", visibility: :PRIVATE}

iex> Trogon.Error.MetadataValue.new(123, :PUBLIC)
%Trogon.Error.MetadataValue{value: "123", visibility: :PUBLIC}