Answers for "try catch"

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
29

javascript try catch

var someNumber = 1;
try {
  someNumber.replace("-",""); //You can't replace a int
} catch(err) {
 console.log(err);
}
Posted by: Guest on June-27-2019
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
0

try catch

try {
  try_statements
}
catch (exception_var) {
  catch_statements
}
finally {
  finally_statements
}
Posted by: Guest on October-07-2021
0

try catch

async function promHandler<T>(
  prom: Promise<T>
): Promise<[T | null, any]> {
  try {
    return [await prom, null];
  } catch (error) {
    return [null, error];
  }
}
Posted by: Guest on September-23-2021

Browse Popular Code Answers by Language