49 #include <emscripten.h> 69 static std::multimap<std::string, ExceptInfo> except_map;
74 inline void TriggerExcept(
const std::string & in_id,
const std::string & in_desc,
bool in_error=
true) {
81 auto it = fail_map.find(
id);
82 if (it != fail_map.end())
return it->second;
89 auto it = fail_map.find(
id);
91 if (it != fail_map.end()) { out = it->second; fail_map.erase(it); }
110 auto it = fail_map.find(
id);
111 if (it != fail_map.end()) fail_map.erase(it);
117 void Notify_impl(std::stringstream &) { ; }
120 template <
typename T,
typename... Ts>
121 void Notify_impl(std::stringstream & ss, T && arg1, Ts &&... args) {
122 ss << std::forward<T>(arg1);
123 Notify_impl(ss, std::forward<Ts>(args)...);
128 template <
typename... Ts>
130 std::stringstream ss;
131 Notify_impl(ss, std::forward<Ts>(args)...);
133 EM_ASM_ARGS({ msg = Pointer_stringify($0); alert(msg); }, ss.str().c_str());
140 template <
typename... Ts>
144 template <
typename... Ts>
148 template <
typename... Ts>
152 template <
typename... Ts>
156 template <
typename... Ts>
const ExceptInfo & GetExcept(const std::string &id)
Get the first waiting exception.
Definition: errors.h:79
void ClearExcept(const std::string &id)
Remove all waiting exceptions of the desginated type.
Definition: errors.h:108
Information about an exception that has occured.
Definition: errors.h:55
bool HasExcept()
Are any exceptions waiting?
Definition: errors.h:99
size_t CountExcepts()
How many exceptions are waiting to be dealt with?
Definition: errors.h:96
void InternalError(Ts &&...msg)
Original library implementers must have made an error.
Definition: errors.h:157
void ClearExcepts()
Remove all waiting exceptions.
Definition: errors.h:105
void Notify(Ts &&...args)
Send information to a program user (via standard error in native mode, or alter in Emscripten) ...
Definition: errors.h:129
std::string desc
A detailed description of thie exception.
Definition: errors.h:57
void NotifyError(Ts &&...msg)
End user has done something resulting in an non-recoverable problem.
Definition: errors.h:145
static const ExceptInfo & GetEmptyExcept()
Function to generate an empty exception (returned when an exception is checked, but none exist...
Definition: errors.h:62
ExceptInfo PopExcept(const std::string &id)
Get and remove a waiting exception.
Definition: errors.h:87
static const PrintStr endl("<br>")
Pre-define emp::endl to insert a "<br>" and thus acting like a newline.
void 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.
Definition: errors.h:74
std::string id
A unique string ID for this exception type.
Definition: errors.h:56
If we are in emscripten, make sure to include the header.
Definition: array.h:37
void NotifyWarning(Ts &&...msg)
End user has done something possibly a problem.
Definition: errors.h:141
static std::multimap< std::string, ExceptInfo > & GetExceptMap()
A map of all exceptions that have occurred and are awaiting to be dealt with.
Definition: errors.h:68
void LibraryError(Ts &&...msg)
Library user has made an error in how they are using the library.
Definition: errors.h:153
bool default_to_error
Should we default to an error (or a warning) if not resolved?
Definition: errors.h:58
void LibraryWarning(Ts &&...msg)
Library user has made an error in how they are using the library.
Definition: errors.h:149