rohitroychowdhury
I want to explicitly render the default debug page of Phoenix.Router.NoRouteError with stacktrace when a certain environment variable is not set and user tries to illegally access a route (/exampleroute).
When an environment variable is not set, in dev environment I want to display the debug stack trace page.
When it happens in prod, I want to display the JSON response {"errors":{"detail":"Not Found"}}.
But when the environment variable is set in both environments, I am using plug controller which allows the user to access the route (/exampleroute) succesfully.
raise Phoenix.Router.NoRouteError, conn: conn, router: MyProjectWeb.router, plug_Status: 404
This is not working from controller plug in dev environment as I am only getting {"errors":{"detail":"Internal Server Error"}} and no stacktrace is getting displayed.
P.S: The debug page is getting correctly displayed for any other unspecified routes.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
siddhant3030
I’m not very clear about your problem. But since I don’t see /fauce route in your available routes. Most probably you’re calling the wrong route.
This problem happens when it does not get the correct route
rohitroychowdhury
I want to know how to explicitly throw this error from controller/conn? I want to render this error debug webpage for a particular route. This error will be deliberately thrown for a particular route.
siddhant3030
You can take a look at this
Phoenix.Controller.action_fallback/1rohitroychowdhury
How do I render the stack trace page using this function?
siddhant3030
why do you need to render stack trace? You can just return the error view which will give you no route found. And you will not get internal server error
josemrb
You can get the stacktrace of the current process using
Process.info(self(), :current_stacktrace)