#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call MyHandler(Handle_uCalc h) { auto uc = uCalc(h); // Retrieve the error code as an integer for display int code = (int)uc.Error().Code(); cout << "Caught Error Code: " << code << endl; // Compare the error code against the ErrorCode enum for logic if (uc.Error().Code() == ErrorCode::Syntax_Error) { cout << "This was a syntax error." << endl; } } int main() { uCalc uc; // Register the error handler uc.Error().AddHandler(MyHandler); // Intentionally cause a syntax error, which will trigger the handler cout << uc.EvalStr("5 *") << endl; }