Two minor things.  Instead of `undefined` use `function` for the first check.  Throw `RuntimeError` instead of `DeveloperError`, since that's what this is.