Tech Junkie Blog - Real World Tutorials, Happy Coding!: JavaScript : Error Handling With try/catch/finally

Thursday, November 11, 2021

JavaScript : Error Handling With try/catch/finally

JavaScript error handling is a lot like other languages where you have the try/catch/finally  statement that you can used.  The basic premise is

     // try some codes here fingers crossed that nothing bad happens
     // oops something bad happened, this is where it gets handled or I tell the user
    // I don't care what happens I am going to execute and get paid

Here is the error handling in action:

Let's say type in the following code with the eval( ) function that you know will cause a "Syntax Error".  The catch statement we are going to display the exception in the console. In finally statement we do another evaluation which will execute regardless of whether the try statement was successful.

    var myvar = "my variable";

    console.log("This is the exception " + ex);
    console.log(eval(1 + 2));

Here is the output for the code above:

1 comment:

  1. error404-store

    - -- Spamming tools --

    1-- cpanel https ssl secure
    2-- shell ssl secure
    3-- web-mail
    4-- smtp
    5-- rdp with send bluster
    6-- scam pages
    7-- ceo or cfo leads

    -- Spy virus slinet Exploits --

    1-- privet rat
    2-- crypter exploits
    3-- privet rdp hosting
    4-- os andriod spy virus
    5-- iso iPhone spy virus
    6-- Nokia spy virus

    - -- scanners brute-force ---

    1-- linux roots
    2-- cpanel scanner
    3-- cpanel bruter
    4-- shell scanner
    5-- smtp scanner
    6-- smtp bruter
    7-- zimbra scanners

    - -------------------

    cpanel,shell,smtp,scampages,sender,ceo or cfo leads,rdp,spyvirus,crypter,exploits,scanners

    Telegram:- @Donsmith000

    icq :- @Donsmith000


Search This Blog