Skip to content

Commit

Permalink
Raise a more specific error when trying to decode nil
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Feb 28, 2025
1 parent 542c034 commit b9ace2f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pythonx.ex
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,11 @@ defmodule Pythonx do
term
end
end

def decode(nil) do
raise ArgumentError,
"Pythonx.decode/1 expects a %Pythonx.Object{}, but got nil. " <>
"Note that Pythonx.eval/2 or the ~PY sigil result in nil, if the " <>
"evaluated code ends with a statement, rather than expression"
end
end

0 comments on commit b9ace2f

Please sign in to comment.