ExDataSketch.Errors (ExDataSketch v0.8.0)

Copy Markdown View Source

Error types for ExDataSketch.

All recoverable errors are represented as structs implementing the Exception behaviour. Functions that validate external input return tagged tuples: {:ok, result} | {:error, %ErrorType{}}.

Error Types

  • NotImplementedError -- operation is stubbed and not yet implemented.
  • InvalidOptionError -- an option value is out of range or of wrong type.
  • DeserializationError -- binary data could not be decoded.
  • IncompatibleSketchesError -- sketches cannot be merged due to parameter mismatch.
  • UnsupportedOperationError -- operation not supported by a structure.
  • InvalidChainCompositionError -- invalid FilterChain stage composition.

Summary

Functions

Wraps an error struct in an error tuple.

Raises a NotImplementedError for the given module and function name.

Wraps a value in an ok tuple.

Functions

error(err)

@spec error(Exception.t()) :: {:error, Exception.t()}

Wraps an error struct in an error tuple.

Examples

iex> ExDataSketch.Errors.error(%ExDataSketch.Errors.InvalidOptionError{message: "bad"})
{:error, %ExDataSketch.Errors.InvalidOptionError{message: "bad"}}

not_implemented!(module, function)

@spec not_implemented!(module(), String.t()) :: no_return()

Raises a NotImplementedError for the given module and function name.

Examples

iex> try do
...>   ExDataSketch.Errors.not_implemented!(ExDataSketch.HLL, "estimate")
...> rescue
...>   e in ExDataSketch.Errors.NotImplementedError -> e.message
...> end
"ExDataSketch.HLL.estimate is not yet implemented"

ok(value)

@spec ok(term()) :: {:ok, term()}

Wraps a value in an ok tuple.

Examples

iex> ExDataSketch.Errors.ok(:value)
{:ok, :value}