Skip to content

Commit b9ace2f

Browse files
committed
Raise a more specific error when trying to decode nil
1 parent 542c034 commit b9ace2f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/pythonx.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,11 @@ defmodule Pythonx do
412412
term
413413
end
414414
end
415+
416+
def decode(nil) do
417+
raise ArgumentError,
418+
"Pythonx.decode/1 expects a %Pythonx.Object{}, but got nil. " <>
419+
"Note that Pythonx.eval/2 or the ~PY sigil result in nil, if the " <>
420+
"evaluated code ends with a statement, rather than expression"
421+
end
415422
end

0 commit comments

Comments
 (0)