:egd Dependency lead to FunctionClauseError

Hello there!

I am currently trying to learn Elixir with the most difficult challenge having to wrap my brain around functional programming opposed to oop.

So, to learn i bought the Udemy Course from Stephen Grider.
I havent finished it yet, so I dont know if it is a good resource or not, but for the time being, i could follow fairly well.
Until now.

One of the Examples is the creation of an identicon.
Everything worked until we created “draw_image” which made use of :egd.

To my knowledge, :egd isnt included by default anymore, so i added

{:egd, github: "erlang/egd"}
to my mix.exs as a dependency (also had to install git), ran the commands and made sure that

mix deps.get
gave me “All dependencies are up to date”.

When then running the programm i encountered the error

** (EXIT from #PID<0.151.0>) shell process exited with reason: an exception was raised:
    ** (FunctionClauseError) no function clause matching in :egd_primitives.span/1
        (egd 0.10.0) c:/Code/Udemy/02Image/identicon/deps/egd/src/egd_primitives.erl:396: :egd_primitives.span('d2')
        (egd 0.10.0) c:/Code/Udemy/02Image/identicon/deps/egd/src/egd_primitives.erl:122: :egd_primitives.filledRectangle/4
        (egd 0.10.0) c:/Code/Udemy/02Image/identicon/deps/egd/src/egd.erl:259: :egd.loop/1

Again, im not too deep into Elixir, and my background in Programming as a whole is fairly shallow, but those are to my knowledge files that were created automatically.
Do I have to edit them? if yes, how?

Which Files would you need, to analyze?
Would really appreciate some help, sorry if this is too trivial, im trying my best out here :smiley:

The root of this trace is :egd.loop, from egd.erl:

Which is sent messages when you call :egd.filledRectangle etc.

loop dispatches to the individual implementations, like :egd_primitives.filledRectangle:

That implementation makes a span between the start and end points on line 122, but :egd_primitives.span/1 expects a list of tuples:

The second line of the stacktrace shows the offending argument: 'd2'. Another way to write that charlist is [100, 50], which suggests something is calling :egd.filledRectangle with integers instead of tuples. That’s a good place to start looking into your code.

2 Likes