user86201: I'm working with a try{} catch(){} exception right now and I want to change a Variable. For this my board has to connect to the Internet and with a try{} statement it will try to do so. If it fails I simply want to set the variables to 0.
  try {
    timeClient.update();
    ntp_seconds  = timeClient.getSeconds();
    ntp_minutes = timeClient.getMinutes();
    ntp_hours = timeClient.getHours();
  } 
    catch () {
     ntp_seconds = 0;
     ntp_minutes = 0;
     ntp_hours = 0;
  }

I am getting this error: Compilation error: expected type-specifier before ')' token
I know that I somehow have to pass my variables into the catch() "function" but somehow I can't pass variables in like I would with normal functions.

user60431: You might want to refresh your knowledge about the try-catch statement by reading the respective chapter in your C++ book.
You need to declare an exception parameter in catch, which you can ignore:
  try {
    timeClient.update();
    ntp_seconds  = timeClient.getSeconds();
    ntp_minutes = timeClient.getMinutes();
    ntp_hours = timeClient.getHours();
  } 
  catch (exception& ignored) {
    ntp_seconds = 0;
    ntp_minutes = 0;
    ntp_hours = 0;
  }


86201: <p>I'm working with a try{} catch(){} exception right now and I want to change a Variable. For this my board has to connect to the Internet and with a try{} statement it will try to do so. If it fails I simply want to set the variables to 0.</p>
<pre><code>  try {
    timeClient.update();
    ntp_seconds  = timeClient.getSeconds();
    ntp_minutes = timeClient.getMinutes();
    ntp_hours = timeClient.getHours();
  } 
    catch () {
     ntp_seconds = 0;
     ntp_minutes = 0;
     ntp_hours = 0;
  }
</code></pre>
<p>I am getting this error: Compilation error: expected type-specifier before ')' token
I know that I somehow have to pass my variables into the catch() &quot;function&quot; but somehow I can't pass variables in like I would with normal functions.</p>
 60431: <p>You might want to refresh your knowledge about the <code>try</code>-<code>catch</code> statement by reading the respective chapter in your C++ book.</p>
<p>You need to declare an exception parameter in <code>catch</code>, which you can ignore:</p>
<pre class="lang-cpp prettyprint-override"><code>  try {
    timeClient.update();
    ntp_seconds  = timeClient.getSeconds();
    ntp_minutes = timeClient.getMinutes();
    ntp_hours = timeClient.getHours();
  } 
  catch (exception&amp; ignored) {
    ntp_seconds = 0;
    ntp_minutes = 0;
    ntp_hours = 0;
  }
</code></pre>
