[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
  • @ damario:
    Character Changer - Max All - Unlock All
  • @ damario:
    if u have ever played it
  • @ QM|T_JinX:
    sorry can realy find a link
  • @ damario:
    have u played it
  • @ QM|T_JinX:
    i played kakarot on ps4 lol
  • @ damario:
    if so try to make as i dont know how to code
  • @ damario:
    the save wizard codes
  • @ damario:
    i use game genie ps3 save editor
  • @ damario:
    add me
  • @ damario:
    discord
  • @ damario:
    ill send screenshots of the rtm tool
  • @ damario:
    my discord name is Damario Culbreath
  • @ QM|T_JinX:
    name isnt working can add you send good name in pm ill check tomorrow im going to bed its 2 in the morning here
  • @ damario:
    sure
  • @ damario:
    whats your discord name
  • @ QM|T_JinX:
    qmt_jinx
  • @ lurch6661:
    night bro
  • Chat Bot:
    Maaellziin is our newest member. Welcome!
  • Chat Bot:
    EvilNatDraxx is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • @ QM|T_JinX:
    hey everybody
  • Chat Bot:
    Christo has joined the room.
  • @ lurch6661:
    happy 420 console crunch
  • Chat Bot:
    Christo has joined the room.
    Chat Bot: Christo has joined the room.