Empirical
Classes | Namespaces | Functions
errors.h File Reference

Tools to help manage various problems in command-line or Emscripten-based applications. More...

#include <iostream>
#include <map>
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

struct  emp::ExceptInfo
 Information about an exception that has occured. More...
 

Namespaces

 emp
 If we are in emscripten, make sure to include the header.
 

Functions

static const ExceptInfo & emp::GetEmptyExcept ()
 Function to generate an empty exception (returned when an exception is checked, but none exist.) More...
 
static std::multimap< std::string, ExceptInfo > & emp::GetExceptMap ()
 A map of all exceptions that have occurred and are awaiting to be dealt with. More...
 
void emp::TriggerExcept (const std::string &in_id, const std::string &in_desc, bool in_error=true)
 Provide information about an exception that needs to be triggered. More...
 
const ExceptInfo & emp::GetExcept (const std::string &id)
 Get the first waiting exception. More...
 
ExceptInfo emp::PopExcept (const std::string &id)
 Get and remove a waiting exception. More...
 
size_t emp::CountExcepts ()
 How many exceptions are waiting to be dealt with? More...
 
bool emp::HasExcept ()
 Are any exceptions waiting? More...
 
bool emp::HasExcept (const std::string &id)
 Are any exceptions of a particular type waiting? More...
 
void emp::ClearExcepts ()
 Remove all waiting exceptions. More...
 
void emp::ClearExcept (const std::string &id)
 Remove all waiting exceptions of the desginated type. More...
 
template<typename... Ts>
void emp::Notify (Ts &&...args)
 Send information to a program user (via standard error in native mode, or alter in Emscripten) More...
 
template<typename... Ts>
void emp::NotifyWarning (Ts &&...msg)
 End user has done something possibly a problem. More...
 
template<typename... Ts>
void emp::NotifyError (Ts &&...msg)
 End user has done something resulting in an non-recoverable problem. More...
 
template<typename... Ts>
void emp::LibraryWarning (Ts &&...msg)
 Library user has made an error in how they are using the library. More...
 
template<typename... Ts>
void emp::LibraryError (Ts &&...msg)
 Library user has made an error in how they are using the library. More...
 
template<typename... Ts>
void emp::InternalError (Ts &&...msg)
 Original library implementers must have made an error. More...
 

Detailed Description

Tools to help manage various problems in command-line or Emscripten-based applications.

Note
This file is part of Empirical, https://github.com/devosoft/Empirical
Date
2016-2018
Note
Status: ALPHA

There are three possible recipiants for all errors/warnings.

There are also three types of problmes to notify about:

In general, most of the content of this file is targeted at providing useful tools for library users; end-users should receive more customized messages and asserts should capture suposedly "impossible" situations that none-the-less occur in the library itself.

NOTES:

Todo:
We should move over to a pure replacement for exceptions.
  • Different types of exceptions can trigger a signal. Actions should return a bool indicating whether the exception was fixed.
  • Remaining exceptions are recorded and passed back up the chain to (hopefully) be caught.
  • Uncaught exceptions should have a default behavior when Resolved. Exceptions could have various resolve times: Next exception added, Next exception check, when ResolveExceptions() is run, End of program, or ASAP. (perhaps)