I’m trying to run dialyzer against my code base. I am using with
and it’s giving me pattern match errors:
And I get:
The pattern
{:ok, _widget}can never match the type
{:error, binary()}
I’m trying to run dialyzer against my code base. I am using with
and it’s giving me pattern match errors:
And I get:
The pattern
{:ok, _widget}can never match the type
{:error, binary()}
I get the same issues CONSTANTLY when I use with
and else
. I worked around it by just making my else
branch in full be:
else err -> handle_controller_errors(err)
I don’t really like it, and occasionally I have to add specialty handlers for failures so I end up encoding those into case’s instead inside the with, it’s all fairly ugly and I really need to make a new ‘with’… >.>
EDIT: Most of my control flow uses the exceptional
library, but some modules I used with
instead and got all those issues, I didn’t expand it out. I need to try the ok
library fully sometime in a module to see how its error handling fares…
It’s not solving the dyalizer problem but…
def run(input) do
with {:ok, widget} <- process_widget(input) do
do_something_with_widget(widget) #noop
else
{:error, reason} ->
#something with reason
end
end # <- this end is missing in your code
else
error ->
{:error, "Received error"}
end