Skip to content

Transform controller action function clause errors into 400's. Closes…#1229

Closed
chrismccord wants to merge 4 commits intomasterfrom
cm-actions-bad-request
Closed

Transform controller action function clause errors into 400's. Closes…#1229
chrismccord wants to merge 4 commits intomasterfrom
cm-actions-bad-request

Conversation

@chrismccord
Copy link
Copy Markdown
Member

@josevalim ready for review. How lenient or strict should we be on the action clause match? I made it so we match on actions that have %Plug.Conn{}, %{}, and any further args.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check only the first argument. :) Also, I think you could just raise a Phoenix specific error in this clause, something like:

defmodule Phoenix.ActionClauseError do
  defexception [conn: ..., plug_status: 400, controller: nil, action: nil]

  # ...
end

And let the error layer take care of it. This way you don't need to log things like file, line and stacktrace and parameters. The error layer will take care of it for us.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on error.

Be more lenient with action argument matching by
considering %Plug.Conn{} as the first argument
enough to catch 400's.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or you should pass the other options in (controller + action) or you should remove them from defexception.

@chrismccord
Copy link
Copy Markdown
Member Author

Merged in 4ad8aa2

@chrismccord chrismccord deleted the cm-actions-bad-request branch October 10, 2015 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants