Skip to content

Commit

Permalink
Fix credo warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jyeshe committed Jan 10, 2025
1 parent 59229fb commit 407eec9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lib/lightning_web/controllers/api/workflows_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ defmodule LightningWeb.API.WorkflowsController do
)
end

defp maybe_handle_error(conn, {:error, :too_many_workflows, %Message{text: error_msg}}, workflow_id) do
reply_422(
conn,
workflow_id,
:project_id,
error_msg
)
end

defp maybe_handle_error(conn, {:error, reason}, workflow_id)
when reason in [:invalid_project_id, :invalid_project_id_format] do
case reason do
Expand Down Expand Up @@ -456,14 +465,6 @@ defmodule LightningWeb.API.WorkflowsController do
"A workflow can have only one trigger enabled at a time."
)

{:error, :too_many_workflows, %Message{text: error_msg}} ->
reply_422(
conn,
workflow_id,
:project_id,
error_msg
)

result ->
result
end
Expand Down
2 changes: 1 addition & 1 deletion test/lightning/projects/provisioner_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ defmodule Lightning.Projects.ProvisionerTest do
assert flatten_errors(changeset) == %{
workflows: [
%{
triggers: [%{id: ["This email address already exists."]}, %{}]
triggers: [%{id: ["This value should be unique."]}, %{}]
}
]
}
Expand Down

0 comments on commit 407eec9

Please sign in to comment.