TheCocoaProject / cordova-plugin-nativestorage

Cordova plugin: Native storage of variables in Android, iOS and Windows
http://thecocoaproject.github.io/
Apache License 2.0
292 stars 106 forks source link

Error in getting item #39

Closed lovestoprogram closed 8 years ago

lovestoprogram commented 8 years ago

So after trying to use get item I get this error

Error in Success callbackId: NativeStorage742808021 : TypeError: error is not a function on line 312 of cordova.js

and Uncaught TypeError: error is not a function on line 314 of cordova.js

Then if I use getItem again, it returns error code 5 and also has the same error on line 312 and 314 of cordova js.

Thank you for your time.

lovestoprogram commented 8 years ago

Never mind. It was completely my fault and the issue is solved.

alokrajiv commented 8 years ago

Thank you.

GillesC commented 8 years ago

Hello, Can you maybe post what was wrong and how you solved it? This for future reference, for developers having the same problem?

On Wed, 14 Sep 2016, 06:45 Alok Rajiv, notifications@github.com wrote:

Thank you.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TheCocoaProject/cordova-plugin-nativestorage/issues/39#issuecomment-246905281, or mute the thread https://github.com/notifications/unsubscribe-auth/AIOhi5P6A80A2mArzt5vMfoYrEtezWBWks5qp3vSgaJpZM4J8VUb .

lovestoprogram commented 8 years ago

Sure. Well I called a this.doSomethingFunction() inside the success callback for setting an item, and the value of this wasn't the object I meant it to be (I forgot about the rules of "this"), so it threw an error. The interesting thing is that when I tried to get the data it triggered the error call 5. I changed this.doSomethingFunction() to nameOfObjectThatMethodBelongsTo.doSomethingFunction() and it worked fine.

I also ran through an issue where the function that I tried to call in the success callback of setItem had a type error in it, and trying to access the value again I think triggered an error 5(I am not completely sure about this case, but it is likely). I fixed the type error, and it worked fine. Reading the .exception error helped in both cases to find the cause of the error.

All in all, if someone calls a method from another object in a success callback and a weird error occurs, see the source code for that function and use .exception to see what the error is and what caused it.