#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call MyHandler(Handle_uCalc h) {
   auto uc = uCalc(h);
   // This handler just logs the error and aborts
   cout << "Error Handler Caught: " << uc.Error().Message() << endl;
}
void ucalc_call MyFunc(uCalcBase::Callback cb) {
   // This function always fails with a custom message
   cb.Error().Raise("Validation failed for input.");
}
int main() {
   uCalc uc;
   uc.Error().AddHandler(MyHandler);
   uc.DefineFunction("Validate()", MyFunc);
   uc.EvalStr("Validate()"); // This call will trigger the error
}