"Object already exists error" in Javascript
My Ja开发者_开发知识库vascript program is creating "Object already exists" errors on both Google Chrome and on Firefox. What kind of mistake could trigger this error message? I am having a hard time debugging this without knowing what the error means.
As per your comment:
All JavaScript is 'open source' (although it can be minified etc), so you can simply search for that exact string. The only result I got that is used as an error thrown is this: http://uxebu.com/blog/2011/04/27/creating-a-persistent-dojo-object-store/.
store.add = function(object, options){
// Get the id
var id = options && options.id || object.id;
// Check if something exists under the given
// id -- StorageJS always returns null when
// there's no data for a certain key.
if(storage.get(id) !== null){
throw new Error("Object already exists"); // <-- did it somehow get here?
}
// We're save to go now! So hand over the
// request to the put() method.
store.put(object, options);
};
Next time, try using a debugger to break on the exception
精彩评论