I use chrome.fileSystem API in my app to open a file. When I click the Cancel button of the file chooser dialog, an error occurs:
Late to the party, but here's how I suppressed the error in a chrome.windows.remove() call, in case it helps anyone else. Instead of
chrome.windows.remove(foo); // unconditional; runtime.lastError not checked
I used
chrome.windows.remove(
foo,
function ignore_error() { void chrome.runtime.lastError; }
);
void evaluates its operand and then returns undefined. I think this code fairly effectively documents that its purpose is to ignore errors :) .
For brevity, ignore_error() could be pulled out of this call and used for multiple chrome API calls, or the name ignore_error could be omitted.
Update In ES6, you can use the shorter arrow function syntax:
chrome.windows.remove( foo, ()=>void chrome.runtime.lastError );
Tested in Chrome 64