Transform controller action function clause errors into 400's. Closes…#1229
Closed
chrismccord wants to merge 4 commits intomasterfrom
Closed
Transform controller action function clause errors into 400's. Closes…#1229chrismccord wants to merge 4 commits intomasterfrom
chrismccord wants to merge 4 commits intomasterfrom
Conversation
lib/phoenix/controller/pipeline.ex
Outdated
Member
There was a problem hiding this comment.
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]
# ...
endAnd 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.
Be more lenient with action argument matching by
considering %Plug.Conn{} as the first argument
enough to catch 400's.
lib/phoenix/exceptions.ex
Outdated
Member
There was a problem hiding this comment.
Or you should pass the other options in (controller + action) or you should remove them from defexception.
Member
Author
|
Merged in 4ad8aa2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@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.