I am trying to open a window by Chrome extension by browser action.
var wid = null;
chrome.windows.get(wid, function(chromeWin) {
    chrome.windows.create({'url': 'https://google.com'}, function(chromeWin) {
            wid = chromeWin.id;
        }
    );
});
To prevent multiple copies of the Window, I am trying to check window id. But if used first time, understandably, it throws error because wid is null.
Error: Invocation of form windows.get(null, function) doesn't match definition windows.get(integer windowId, optional object getInfo, function callback)
I tried to use try..catch block and in catch I am handling "wid is null" case.
try {
    var wid = null;
    chrome.windows.get(wid, function(chromeWin) {
        chrome.windows.create({'url': 'https://google.com'}, function(chromeWin) {
                wid = chromeWin.id;
            }
        );
    });
}
catch(error) {
    chrome.windows.create({'url': 'https://google.com'}, function(chromeWin) {
            wid = chromeWin.id;
        }
    );      
}
But try..catch is not catching the "wid is null" case. I know if clause may help for my experiment but I want to learn why try behaves this way.
Why is try..catch not caching the error and how can I open windows without copies in Chrome?
 
     
    