Throw not_found error in API v2 when a batch is not found

pull/7584/head
POA 1 year ago
parent 921e01dc9a
commit bea348df48
  1. 21
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex

@ -28,16 +28,19 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do
""" """
@spec batch(Plug.Conn.t(), map()) :: Plug.Conn.t() @spec batch(Plug.Conn.t(), map()) :: Plug.Conn.t()
def batch(conn, %{"batch_number" => batch_number} = _params) do def batch(conn, %{"batch_number" => batch_number} = _params) do
{:ok, batch} = case Reader.batch(
Reader.batch( batch_number,
batch_number, necessity_by_association: @batch_necessity_by_association,
necessity_by_association: @batch_necessity_by_association, api?: true
api?: true ) do
) {:ok, batch} ->
conn
|> put_status(200)
|> render(:zkevm_batch, %{batch: batch})
conn {:error, :not_found} = res ->
|> put_status(200) res
|> render(:zkevm_batch, %{batch: batch}) end
end end
@doc """ @doc """

Loading…
Cancel
Save