Check out example codes for "c++ try". It will help you in understanding the concepts better.

Code Example 1

// exceptions
#include <iostream>
using namespace std;

int main () {
  try
  {
    throw 20;
  }
  catch (int e)
  {
    cout << "An exception occurred. Exception Nr. " << e << '\n';
  }
  return 0;
}

Code Example 2

#include <iostream> 
using namespace std; 
  
int main() 
{ 
    try  { 
       throw 10; 
    } 
    catch (char *excp)  { 
        cout << "Caught " << excp; 
    } 
    catch (...)  { 
        cout << "Default Exception\n"; 
    } 
    return 0; 
}

Code Example 3

try {
	//do
} catch (...){
	//if error do
}

Learn ReactJs, React Native from akashmittal.com