When you say it doesn't work, what is the problem? What was the code you tried to put in the error handler?
Export/import is described in more detail here:
http://www.breezejs.com/documentation/exportimport
But, I think the short answer is that in order to store the data into the cache after each of your queries and saves, you would write something like this.
var exportedData = manager.exportEntities();
window.localStorage.setItem("myLocalStorageName", exportedData);
With this code being executed in both the query or save promise 'then()' callback.
Then, when you detect a 'lost' connection, you could restore the data like this
var
importedData = window.localStorage.getItem("myLocalStorageName");
manager.importEntities(importedData);
or you could import it into a completely new EntityManager.
One thing to remember, if you have lost your connection, you might want all future queries (until the connection comes back) to go to the local cache by default. This can be accomplised by calling
manager.defaultQueryOptions = new QueryOptions({ fetchStrategy: FetchStrategy.FromLocalCache });
Going forward, one of the features we've been considering is raising an
EntityManager event on each 'Save' or 'Query'; with this you could
simply store the exported cache each time the event was called instead of having to add this code to the callback of each query or save.
Please feel free to add your vote to this feature using the
feedback mechanism on the web site. ( small icon on the right side of
any Breeze website page labeled "Feedback"). This allows other breeze
users to vote on the feature and obviously helps us decide which
ones to work on next.