Spek.EvaluationError exception (Spek v0.2.0)

Copy Markdown View Source

Error representing a failed rule evaluation.

Summary

Types

t()

Struct returned or raised if an authorization check fails.

Functions

Returns a new EvaluationError struct.

Collects the error results with Spek.collect_results/2 and puts them into the given EvaluationError struct.

Returns a new EvaluationError struct that contains the given expression.

Types

t()

@type t() :: %Spek.EvaluationError{
  __exception__: term(),
  expression: Spek.expression() | nil,
  message: String.t(),
  results: [term()] | nil
}

Struct returned or raised if an authorization check fails.

expression contains the parts of the policy expression that were performed and their results. Depending on the evaluation function used, this may be the complete expression, or only the parts of it that were evaluated until a decision was made.

results contains the collected error reasons as returned by Spek.collect_results/2.

Functions

new(message \\ "rule evaluation failed")

@spec new(String.t()) :: t()

Returns a new EvaluationError struct.

put_results(error)

@spec put_results(t()) :: t()

Collects the error results with Spek.collect_results/2 and puts them into the given EvaluationError struct.

with_expression(message \\ "rule evaluation failed", expression)

@spec with_expression(String.t(), Spek.expression()) :: t()

Returns a new EvaluationError struct that contains the given expression.