From 518b6bc6ed78a06cea8e3fb02b7c68d9390cf209 Mon Sep 17 00:00:00 2001 From: Johanna Larsson Date: Wed, 15 Jul 2026 08:59:24 +0100 Subject: [PATCH] Clarify the Store behavior error values The only thing we use is `:not_found`, but I put a `:backend_error` in there for anything else --- lib/latch/error/store.ex | 8 +++++++- lib/latch/store.ex | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/latch/error/store.ex b/lib/latch/error/store.ex index 919e0db..6805296 100644 --- a/lib/latch/error/store.ex +++ b/lib/latch/error/store.ex @@ -14,6 +14,8 @@ defmodule Latch.Error.Store do * `:delete_expired_requests` """ + alias Latch.Store, as: StoreBehavior + defexception [:action, :did, :reason] @type action :: @@ -25,7 +27,11 @@ defmodule Latch.Error.Store do | :put_request | :delete_expired_requests - @type t :: %__MODULE__{action: action(), did: String.t() | nil, reason: term() | nil} + @type t :: %__MODULE__{ + action: action(), + did: String.t() | nil, + reason: StoreBehavior.reason() + } @impl Exception def message(%__MODULE__{action: action, did: did, reason: reason}) do diff --git a/lib/latch/store.ex b/lib/latch/store.ex index 3ff3503..f6b2869 100644 --- a/lib/latch/store.ex +++ b/lib/latch/store.ex @@ -16,8 +16,9 @@ defmodule Latch.Store do @type state :: binary() @type did :: binary() - # TODO fix the term here, it should be specific atoms not "something" - @type store_error :: {:error, :not_found} | {:error, term()} + + @type reason :: :not_found | :backend_error + @type store_error :: {:error, reason()} @doc """ Store an inflight request under `state` for at least `ttl_seconds`. -- 2.51.2