[JS] Try & Catch statements

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Oblivion

Member
CC Dev Team
Jul 25, 2016
26
32
73
Try and Catch statement example.
You will need at least some knowledge of JavaScript if you want to use this example.

Example
Code:
try {
    //Try statement lets you test your code for errors
    console.log('Hello');
} catch (err) {
    //Catch statement "catches" any errors from your try statement and executes whatever you've placed as your error handling
    console.error('error occurred : ' + err);
}

Step by step guide
  • Create your try statement:
Code:
try {
  
}

  • Add your code inside the try statement:
Code:
try {
    console.log('Hello');
}

  • Add a catch statement to the end of your try statement and make a function called err
Code:
catch (err) {
    console.error('error occurred : ' + err);
}

  • Now run your code and if it catches any errors it will console.error() them.
 
  • Like
Reactions: Dana White
General chit-chat
Help Users
  • @ lurch6661:
    need a wireless one
  • @ QM|T_JinX:
    well when you get your money maybe get one
  • @ QM|T_JinX:
    im gonna buy one this month but i also want to get the edg controler hahaha
  • @ QM|T_JinX:
    edge
  • @ QM|T_JinX:
    but let me know if you realy gonna install mw3 and if you want to play some matches we can work on a menu for you then
  • @ QM|T_JinX:
    im gonna watch a movie so catch you on the flip side
  • @ lurch6661:
    ok cool bro tc
  • @ lurch6661:
    i will download it for sure then
  • @ QM|T_JinX:
    keep in mind i do think there are free ones you maybe have to buy one and also dont do it on your main account make new one
  • @ ZockMock131:
    Hello there, is the Admin online?
  • @ QM|T_JinX:
    well im not a admin but maybe i can help /
  • @ ZockMock131:
    I want to delete my old account permantly bcs i dont use it anymore
  • @ QM|T_JinX:
    there is no option to delete a account for members im afraid
  • @ ZockMock131:
    Why is that bro
    ?
  • @ QM|T_JinX:
    not sure
  • Chat Bot:
    Christo has joined the room.
  • Chat Bot:
    nodikx is our newest member. Welcome!
  • Chat Bot:
    KrxzyMods is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    Christo has joined the room.
  • Chat Bot:
    Christo has joined the room.
  • @ lurch6661:
    zap
    @ lurch6661: :weed: