Factor out the common code between this and `toThrowDeveloperError`.  They can use basically the same implementation.