Answers for "try catch block"

1

try catch haxe

import haxe.Exception;

class Main {
  static function main() {
    try {
      try {
        doSomething();
      } catch(e:Exception) {
        trace(e.stack);
        throw e; //rethrow
      }
    } catch(e:Exception) {
      trace(e.stack);
    }
  }

  static function doSomething() {
    throw new Exception('Terrible error');
  }
}
Posted by: Guest on July-23-2020
21

java try catch

try {
  // Code that may have error
} catch(ErrorName e){
  // Another code
}
Posted by: Guest on November-26-2019
7

try catch java

public class MyClass {
  public static void main(String[ ] args) {
    try {
      int[] myNumbers = {1, 2, 3, 4, 5, 6};
      System.out.println(myNumbers[10]);
    } catch (Exception e) {
      System.out.println("Something went wrong. check again");
    }
  }
}
Posted by: Guest on July-17-2020
6

try block in java

try {
  //  Block of code to try
}
catch(Exception e) {
  //  Block of code to handle errors
}
Posted by: Guest on May-02-2020
6

try catch exception

First try block try to handle it
if not then catch block will handle it.
Finally block will executed regardless
of the outcome
Posted by: Guest on January-05-2021
-1

try catch block

const input = require('readline-sync');

let animals = [{name: 'cat'}, {name: 'dog'}];
let index = Number(input.question("Enter index of animal:"));

try {
   console.log('animal at index:', animals[index].name);
} catch(err) {
   console.log("We caught a TypeError, but our program continues to run!");
   console.log("You tried to access an animal at index:", index);
}

console.log("the code goes on...");
Posted by: Guest on May-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language