Code View

// SPDX-License-Identifier: MIT
#include "errors.hh"

#include <cstring>
#include <fstream>
#include <iostream>

#include <unistd.h>

namespace
{
  void Load( std::string const &path )
  {
    std::ifstream file( path );

    if ( ! file )
    {
      app::errors::ThrowConfigMissing( path );
    }
  }
}

int main( int argc, char **argv )
{
  // Only when asked: the smoke test does not write to the system log.
  if ( argc > 1 && std::strcmp( argv[1], "--syslog" ) == 0 )
  {
    app::errors::LogStarted( static_cast<long>( getpid( ) ) );
  }

  try
  {
    Load( "/nonexistent/app.conf" );
  }
  catch ( std::exception const &e )
  {
    std::cout << "caught: " << e.what( ) << std::endl;
  }

  app::errors::FatalError( 7 );   // does not return: std::exit( 2 )
}