Javascript duplicate error?

Does it provide try ... catch(e)the same service as On Error Resume Nextin VB?

I have a page that uses several jQuery plugins, as well as some functions that I wrote myself. Eliminating all possible exceptions will require a lot of work.

Currently, I want to say that a script, in order not to break, would be fatal errors. How to do this when I use plugins?

+5
source share
2 answers

Yes, try/ catchprovides a way to capture errors, although, unlike On Error Resume Next, you decide to deal with an error in the block catchor not at all.

, VB :

on error resume next
DoSomethingUnsavory
if err.number <> 0 then ...
on error goto 0 ' you DO do this, right?

JS :

try {
    doSomethingUnsavory();
}
catch (e) {
    // handle the unsavoriness if needed
}

, , yadda yadda. . !

+6

, javascript ON ERROR RESUME NEXT,

try
{
    var providerRateAvg = data.entry.gd$rating.average;
}
catch(e)
{}
+3

All Articles