Skip to content

scl::could_not_open_error Documentation

WizardCarter edited this page Aug 7, 2018 · 1 revision

scl::could_not_open_error

scl::could_not_open_error is a custom exception within SCL. It is thrown when a config_file cannot be opened.

Public Member Functions

virtual const char* what() const throw()

Returns a series of characters explaining the exception.

Example of Usage

Writing Safe Code with SCL

To make sure your code is as safe as possible, you should wrap your operations that use SCL within try-catch block.

try {
  scl::config_file file("example.config", scl::config_file::READ);
  int i = file.get<int>("integer value");

  //do something with int here...


  //file implicitly closed by destructor
} catch (std::exception& e) {
  //handle the issue opening the file here
  std::cerr << "Error: Exception thrown! Details : " << e.what() << '\n';
}

Clone this wiki locally