Skip to content Skip to sidebar Skip to footer

How To Detect Errors Of Invalid Url In Worker Api

If I run the following (at least on Chromium): var w = null; try { w = new Worker( 'NONEXISTENT_URL' ); } catch ( e ) { console.log( 'CAUGHT: ' + e ); } console.log( w );

Solution 1:

You can get error using onerror event handler.

var worker = newWorker('aURL');

worker.onerror = function () {
    console.log( 'error' );
};

If the URL has an invalid syntax or if the same-origin policy is violated a DOMException of type SECURITY_ERR is thrown.

Post a Comment for "How To Detect Errors Of Invalid Url In Worker Api"