This only happens because of the way line 216 and friends above are structured.
This prevents users of this library from seeing what the error actually was; is that intended?  (It also creates the need for the extra defensive coding here.)