From 749afc3fe86ce684f84118a28bd9891f31eb37f6 Mon Sep 17 00:00:00 2001 From: hswick Date: Thu, 30 Aug 2018 22:25:09 -0500 Subject: [PATCH] Improved error message for invalid arg count to constructor --- lib/exw3.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/exw3.ex b/lib/exw3.ex index ff9c522..3a000ba 100644 --- a/lib/exw3.ex +++ b/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))