Initial commit

This commit is contained in:
2026-07-03 16:31:37 +07:00
commit 899c7c637d
1939 changed files with 641750 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
namespace CeresSharp.Exceptions;
/// <summary>
/// Base exception for all Ceres-related errors.
/// </summary>
public class CeresException : Exception
{
/// <summary>
/// Gets the error code associated with this exception.
/// </summary>
public CeresErrorCode ErrorCode { get; }
public CeresException(CeresErrorCode errorCode, string? message = null)
: base(message ?? GetDefaultMessage(errorCode))
{
ErrorCode = errorCode;
}
public CeresException(CeresErrorCode errorCode, string? message, Exception? innerException)
: base(message ?? GetDefaultMessage(errorCode), innerException)
{
ErrorCode = errorCode;
}
private static string GetDefaultMessage(CeresErrorCode errorCode) => errorCode switch
{
CeresErrorCode.Success => "Operation succeeded",
CeresErrorCode.NullPointer => "Null pointer argument",
CeresErrorCode.InvalidParameter => "Invalid parameter value",
CeresErrorCode.InvalidEnum => "Invalid enum value",
CeresErrorCode.Exception => "C++ exception occurred",
CeresErrorCode.OutOfMemory => "Memory allocation failed",
CeresErrorCode.InvalidOperation => "Invalid operation for current state",
CeresErrorCode.BufferTooSmall => "Output buffer too small",
CeresErrorCode.NotFound => "Resource not found",
CeresErrorCode.AlreadyExists => "Resource already exists",
_ => $"Unknown error code: {errorCode}"
};
}
/// <summary>
/// Error codes returned by Ceres wrapper functions.
/// </summary>
public enum CeresErrorCode
{
Success = 0,
NullPointer = 1,
InvalidParameter = 2,
InvalidEnum = 3,
Exception = 4,
OutOfMemory = 5,
InvalidOperation = 6,
BufferTooSmall = 7,
NotFound = 8,
AlreadyExists = 9
}