federator: don't nest {:error, _} tuples
It makes decisions based on error sources harder since all possible nesting levels need to be checked for. As shown by the return values handled in the receiver worker something else still nests those, but this is a first start.
This commit is contained in:
parent
8e5defe6ca
commit
0ba5c3649d
2 changed files with 8 additions and 4 deletions
|
@ -117,7 +117,11 @@ def perform(:incoming_ap_doc, params) do
|
|||
e ->
|
||||
# Just drop those for now
|
||||
Logger.debug(fn -> "Unhandled activity\n" <> Jason.encode!(params, pretty: true) end)
|
||||
{:error, e}
|
||||
|
||||
case e do
|
||||
{:error, _} -> e
|
||||
_ -> {:error, e}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,13 +24,13 @@ def perform(%Job{args: %{"op" => "incoming_ap_doc", "params" => params}}) do
|
|||
{:discard, :already_present}
|
||||
|
||||
# invalid data or e.g. deleting an object we don't know about anyway
|
||||
{:error, {:error, {:validate, issue}}} ->
|
||||
{:error, {:validate, issue}} ->
|
||||
Logger.info("Received invalid AP document: #{inspect(issue)}")
|
||||
{:discard, :invalid}
|
||||
|
||||
# rarer, but sometimes there’s an additional :error in front
|
||||
{:error, {:error, {:error, {:validate, issue}}}} ->
|
||||
Logger.info("Received invalid AP document: (3e) #{inspect(issue)}")
|
||||
{:error, {:error, {:validate, issue}}} ->
|
||||
Logger.info("Received invalid AP document: (2e) #{inspect(issue)}")
|
||||
{:discard, :invalid}
|
||||
|
||||
{:error, _} = e ->
|
||||
|
|
Loading…
Reference in a new issue