BAM.Error exception (BAM v0.1.0)

Copy Markdown View Source

Failure returned by the public BAM API.

message is safe to show to a caller. It names the format, the operation, and a file offset or line when those are known. It does not include file bytes. reason is an atom defined by this library. Tag names, reference names, and other file bytes are never turned into atoms.

category is the stable class a caller can match on. context carries small identifiers such as :format, :path, :offset, :virtual_offset, and :line.

Summary

Functions

Error for an operation on a handle that was already released.

Error for a caller value this function does not accept.

Error for a path that does not exist.

Error for a feature this version does not implement.

Types

category()

@type category() ::
  :not_implemented
  | :not_found
  | :io
  | :closed
  | :invalid_argument
  | :invalid_magic
  | :truncated
  | :checksum
  | :resource_limit
  | :corrupt
  | :unsupported

t()

@type t() :: %BAM.Error{
  __exception__: term(),
  category: category(),
  cause: term(),
  context: map(),
  message: String.t(),
  reason: atom()
}

Functions

closed(operation)

@spec closed(atom()) :: t()

Error for an operation on a handle that was already released.

invalid_argument(reason, message, context \\ %{})

@spec invalid_argument(atom(), String.t(), map()) :: t()

Error for a caller value this function does not accept.

new(category, reason, message, context \\ %{})

@spec new(category(), atom(), String.t(), map()) :: t()

Builds an error.

context is merged with %{format: format} when :format is passed separately through the map the caller already built.

not_found(path)

@spec not_found(Path.t()) :: t()

Error for a path that does not exist.

unsupported(reason, message, context \\ %{})

@spec unsupported(atom(), String.t(), map()) :: t()

Error for a feature this version does not implement.