title: How to countercheck a Boost Error Code appropriately?
body: <p>I have a callback function which is bound to a <code>boost::asio::deadline_timer</code>. Now the function is called when the timer is cancelled or it expires. Since I need to distinguish between this two cases I need to check the passed Error code. The basic code would be like this:</p>
  
  <pre><code>void CameraCommand::handleTimeout(const boost::system::error_code&amp; error)
  {
      std::cout &lt;&lt; "\nError: " &lt;&lt; error.message() &lt;&lt; "\n";
      return;
  }
  </code></pre>
  
  <p>Now when the Handler is called because the timer expired the error code is <code>Success</code>, when the timer is cancelled the error code is <code>Operation canceled</code>.</p>
  
  <p>Now my question would be, how to appropriately check what happened?</p>
  
  <p>Suggestion 1:</p>
  
  <pre><code>if( error.message() == "Success" )
  {
       // Timer expired
  }
  else
  {
       // Timer cancelled
  }
  </code></pre>
  
  <p>Suggestion 2:</p>
  
  <pre><code>if( error.value() == 0 )
  {
       // Timer expired
  }
  else
  {
       // Timer cancelled
  }
  </code></pre>
  
  <p>Now my question is - is there any way to compare the error byitself and not by value or by string? Something like ( this is made up now )</p>
  
  <pre><code>if ( error == boost::system::error::types::success )
  </code></pre>
  
  <p>Because what I don't like about the first suggestion is that I need to create a string just for check, which is kinda unnecessary in my opinion. The second way has the disadvantge that I need to look up all the error codes if I want to check for something other?
  So are there any enums or ways to check for the error or do I have one of the two suggested ways?</p>