Fixed error getting worng referenc to onerror function

Change-Id: I248e869984efa4deb4618c385f8c870917094856