Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a handler for resources not found #24

Open
frm opened this issue Nov 13, 2020 · 2 comments · May be fixed by #29
Open

Add a handler for resources not found #24

frm opened this issue Nov 13, 2020 · 2 comments · May be fixed by #29
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@frm
Copy link
Contributor

frm commented Nov 13, 2020

If a resource is not found, we're currently calling the policy with nil for the resource value. This means that a lot of times, the policies will have a function branch pattern matching on nil and calling a FallbackController or specific handler.

We should add that as an alternative, similar to the current unauthorised handler.

Since both the new handler and the unauthorised one are plugs, we should also update the README with an example using a MyAppWeb.FallbackController as the handler

@frm frm added enhancement New feature or request good first issue Good for newcomers help wanted and removed help wanted labels Nov 13, 2020
@naps62
Copy link
Member

naps62 commented Nov 13, 2020

Agree, but I don't think we should care about a fallback controller at all.
If people want to reach a fallback controller, the way to do that is to return an error tuple. So we can allow the option of doing that when the resource is nil, but I'd say it's up to the user to catch that on the fallback controller

@frm
Copy link
Contributor Author

frm commented Nov 17, 2020

The fallback controller was just an example for the README. A custom unauthorized handler that would defer errors to the fallback controller, to keep all the error handling logic in the same module (I've found myself doing this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants