4
0
Fork 0

Improved error message for invalid arg count to constructor

pull/17/head
hswick 6 years ago
parent 26b9d64651
commit 749afc3fe8
  1. 6
      lib/exw3.ex

@ -555,8 +555,10 @@ defmodule ExW3 do
input_types = Enum.map(constructor["inputs"], fn x -> x["type"] end)
types_signature = Enum.join(["(", Enum.join(input_types, ","), ")"])
if Enum.count(input_types) != Enum.count(arguments) do
throw "Number of provided arguments is invalid"
arg_count = Enum.count(arguments)
input_types_count = Enum.count(input_types)
if input_types_count != arg_count do
raise "Number of provided arguments to constructor is incorrect. Was given #{arg_count} args, was looking for #{input_types_count}."
end
bin <> (ExW3.encode_data(types_signature, arguments) |> Base.encode16(case: :lower))

Loading…
Cancel
Save