uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026

Warning

uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.

ErrorCode

Enum

Product: 

Class: 

Error numbers/messages that uCalc may return

Name Value Description
None

No error

FloatInexact 1

Inexact result

FloatUnderflow 2

Floating point underflow

FloatOverflow 4

Floating point overflow

FloatDivisionByZero 8

Division by 0

FloatInvalid 16

Invalid floating point value

Dynamically_Defined 256

Dynamically defined user error

Syntax_Error

Syntax error

Undefined_Identifier

Undefined identifier

FileNotFound

File not found

Unrecognized_Token

Unrecognized token

Unrecognized_Command

Unrecognized command

Datatype_Mismatch

Data type mismatch

Invalid_Argument_Count

Invalid number of arguments

Invalid_Definition

Invalid definition

Bracket_Error

Bracket delimiter error

Undefined_Callback

Undefined callback

ErrorMessageAlreadyDefined

Error message already defined

ItemCannotBeModified

This item cannot be modified

Unrecognized_Class_Member

Unrecognized class member

Unrecognized_Namespace_Member

Unrecognized namespace member

Unbalanced_Quote

Unbalanced quote

ValueCannotBeAssigned

Value cannot be assigned here

ReParseOverflow

Reparsing has passed the specified limit

Array_Bounds_Exceeded

Array or list bound exceeded

Remarks

This is the "built-in" list of errors that uCalc can return or that you can raise with [topic: uCalc.Callback.ErrorRaise]. If no error was raised, then ErrorCode.None is returned.

[topic: uCalc.Callback.ErrorRaiseMessage] internally calls the Dynamically_Defined member.

Examples

A practical example of a proactive error handler that automatically defines undeclared variables on the fly, allowing the expression to successfully resume execution.

ID: 1190

				
					using uCalcSoftware;

var uc = new uCalc();

// This handler automatically defines variables when they are first used.
static void AutoDefineHandler(Handle_uCalc h) {
   var uc = new uCalc(h);
   // Check if the error is specifically an undefined identifier
   if (uc.Error.Code == ErrorCode.Undefined_Identifier) {
      Console.WriteLine($"Handler: '{uc.Error.Symbol}' is undefined. Defining it now.");
      uc.DefineVariable(uc.Error.Symbol);

      // Tell the engine to resume the operation
      uc.Error.Response = ErrorHandlerResponse.Resume;
   }
}


uc.Error.AddHandler(AutoDefineHandler);

// 'my_var' doesn't exist yet, but the handler will create it.
var result = uc.EvalStr("my_var = 100; my_var = my_var * 2");

Console.WriteLine($"Final result: {result}");
				
			
Handler: 'my_var' is undefined. Defining it now.
Final result: 200
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

// This handler automatically defines variables when they are first used.
void ucalc_call AutoDefineHandler(Handle_uCalc h) {
   auto uc = uCalc(h);
   // Check if the error is specifically an undefined identifier
   if (uc.Error().Code() == ErrorCode::Undefined_Identifier) {
      cout << "Handler: '" << uc.Error().Symbol() << "' is undefined. Defining it now." << endl;
      uc.DefineVariable(uc.Error().Symbol());

      // Tell the engine to resume the operation
      uc.Error().Response(ErrorHandlerResponse::Resume);
   }
}

int main() {
   uCalc uc;
   uc.Error().AddHandler(AutoDefineHandler);

   // 'my_var' doesn't exist yet, but the handler will create it.
   auto result = uc.EvalStr("my_var = 100; my_var = my_var * 2");

   cout << "Final result: " << result << endl;
}
				
			
Handler: 'my_var' is undefined. Defining it now.
Final result: 200
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   '// This handler automatically defines variables when they are first used.
   Public Sub AutoDefineHandler(ByVal h As Handle_uCalc)
      Dim uc As New uCalc(h)
      '// Check if the error is specifically an undefined identifier
      If uc.Error.Code = ErrorCode.Undefined_Identifier Then
         Console.WriteLine($"Handler: '{uc.Error.Symbol}' is undefined. Defining it now.")
         uc.DefineVariable(uc.Error.Symbol)
         
         '// Tell the engine to resume the operation
         uc.Error.Response = ErrorHandlerResponse.Resume
      End If
   End Sub
   
   Public Sub Main()
      Dim uc As New uCalc()
      uc.Error.AddHandler(AddressOf AutoDefineHandler)
      
      '// 'my_var' doesn't exist yet, but the handler will create it.
      Dim result = uc.EvalStr("my_var = 100; my_var = my_var * 2")
      
      Console.WriteLine($"Final result: {result}")
   End Sub
End Module
				
			
Handler: 'my_var' is undefined. Defining it now.
Final result: 200