kuon
Prevent Ecto.NoResultsError in logs in live views
In my live views, I go get! which will raise Ecto.NoResultsError when there is no result.
Live view handles it properly, as it does redirect to my 404 page.
Now, if the live view is connected (for example if I hit back after a live redirect and the object does no longer exist), I get the Ecto.NoResultsError error in the logs before the live view redirects to the error page.
The app works fine, but those Ecto.NoResultsError are “normal”, is there a way to prevent them in the logs?
Most Liked
kuon
Well, the error is not in the normal flow of operation, it is “exceptional”, it requires the user to navigate to a page that do not exist with live view, so this require the page to disappear while the user is navigating. Using get! simplifies the code a lot and make it easier to read, when we load the resource, we don’t want to handle the case when it does not exist, because this should not happen, except under special conditions which are “exceptional”.
But the error gravity is low, and for this reason, I’d like to not have it logged in our server logs.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









