javascript - Testing URL schemes with try/catch -


i'm trying test url schemes via javascript try/catch blocks catch blocks not being executed. safari skips them entirely , don't understand why?!

function open_twitter() {         if (!is_ios){ //made unequal ios test on macbook           try {             window.location = "twitter://"; //fails , should go catch block           } catch (e) { //skipped             try { //skipped               window.location = twitterrific_url_scheme; //skipped             } catch (e) { //skipped               null; //skipped             } //skipped           } //skipped         } else {           window.open(twitter_url, "_blank");         }       } 

does have idea why happening?

i want code test first url scheme. if isn't successful should (in theory) go catch block , run code inside in case try block again next url scheme test , on , forth. doesn't happen?! i'm confused...

try catch doesn't work wrote, you'll need provide catch exception, else doesn't know bad happened.

see these docs : https://developer.mozilla.org/en-us/docs/web/javascript/reference/statements/try...catch

try/catch should used simple test custom exception. example,

try { if(false==false) {     throw "myexception"; // generates exception } catch (e) {    // statements handle exceptions    logmyerrors(e); // pass exception object error handler } 

as can see, try should test , return exception if condition met.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -