(#2545) - throw errors instead of returning them

strictly speaking this is a breaking change as you can't use error name to identify the errors, but error.name means something kinda specific in js so hopefully thats ok.