It seems to me that you shouldn't set the result if you are going to call onerror