Skip to content

Instantly share code, notes, and snippets.

@laser
Created April 21, 2014 22:36
Show Gist options
  • Save laser/11158913 to your computer and use it in GitHub Desktop.
Save laser/11158913 to your computer and use it in GitHub Desktop.
RPC Batch Errors
// Errors from Batch Request (Barrister)
initApp(function(err, TodoManager, BatchTodoManager) {
TodoManager.readTodos(function(err, todos) {
for (var i = 0, len = todos.length; i < len; i++) {
BatchTodoManager.deleteTodo(todos[i]['id']);
}
BatchTodoManager.send(function(err, results) {
var result, i, len;
for (i = 0, len = results.length; i < len; i++) {
result = results[i];
if (result.error) {
alert(result.error.code); // will fire once, for the last todo
}
else {
console.log(result.result); // will output for as many todos as we had, minus 1
}
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment