Handle JSAPI OOM failures by task failure as soon as possible.

We already ensure to fail the task if GetProtoObject returns null, as we don't
have a useful way to handle OOM, and we don't wish to thread the failure
through to some place where we could handle it in a useful way.

Unfortunately, we cannot ensure through the type system that none of those
functions returns null, so we use assertions to check it dynamically.
Merge pull request #2668 from Ms2ger/CreateInterfaceObjects-failures

Handle JSAPI OOM failures by task failure as soon as possible.