View Source Errata.Env (Errata v0.8.1)

A struct that holds compile time environment information that is used for the :env field of Errata error types.

This struct is a subset of Macro.Env and includes the following fields:

  • context - the context of the environment; it can be nil (default context), :guard (inside a guard) or :match (inside a match)
  • context_modules - a list of modules defined in the current context
  • file - the current absolute file name as a binary
  • function - a tuple as {atom, integer}, where the first element is the function name and the second its arity; returns nil if not inside a function
  • line - the current line as an integer
  • module - the current module name
  • stacktrace - the stacktrace for the current process at the time of creation

Summary

Types

Type to represent an Errata.Env struct as a plain, JSON-encodable map.

t()

Type to represent the :env field of error structs.

Functions

Creates a new Errata.Env struct from the given Macro.Env struct.

Converts the given Errata.Env struct to a plain, JSON-encodable map.

Types

@type env_map() :: %{
  module: module(),
  function: String.t(),
  file: Macro.Env.file(),
  line: Macro.Env.line(),
  file_line: String.t()
}

Type to represent an Errata.Env struct as a plain, JSON-encodable map.

@type t() :: %Errata.Env{
  context: Macro.Env.context(),
  context_modules: Macro.Env.context_modules(),
  file: Macro.Env.file(),
  function: Macro.Env.name_arity() | nil,
  line: Macro.Env.line(),
  module: module(),
  stacktrace: Exception.stacktrace() | nil
}

Type to represent the :env field of error structs.

This struct is a subset of Macro.Env.

Functions

Link to this function

new(env, stacktrace \\ nil)

View Source

Creates a new Errata.Env struct from the given Macro.Env struct.

@spec to_map(t()) :: env_map()

Converts the given Errata.Env struct to a plain, JSON-encodable map.