LetMe.UnauthorizedError exception (LetMe v3.0.2)

Copy Markdown View Source

Raised by LetMe.Policy.authorize!/4 if a request is unauthorized.

Summary

Types

t()

Struct returned or raised if an authorization check fails.

Functions

Returns an error struct with the given message and without an expression.

Types

t()

@type t() :: %LetMe.UnauthorizedError{
  __exception__: term(),
  expression: Spek.expression() | nil,
  message: String.t()
}

Struct returned or raised if an authorization check fails.

expression contains the parts of the policy expression that were evaluated and their results. Checks are evaluated lazily. The evaluation order follows the expression as Spek.optimize/1 rewrote it at compile time, which is not the order the allow/1 and deny/1 calls were written in.

The expression reflects the checks until a decision is made, but it does not reflect the complete authorization policy.

Functions

new(message \\ "unauthorized")

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

Returns an error struct with the given message and without an expression.

Examples

iex> LetMe.UnauthorizedError.new()
%LetMe.UnauthorizedError{message: "unauthorized", expression: nil}

iex> LetMe.UnauthorizedError.new("forbidden")
%LetMe.UnauthorizedError{message: "forbidden", expression: nil}