From 2162178cb7e209e9f060748842e1c4782a2ab852 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 17 Aug 2024 21:33:23 -0400 Subject: refactor: cipher utils update and simplify --- .../VNLib.Utils.Cryptography.Noscrypt/src/NCUtil.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/NCUtil.cs') diff --git a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/NCUtil.cs b/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/NCUtil.cs index 49c66c1..307bbc1 100644 --- a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/NCUtil.cs +++ b/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/NCUtil.cs @@ -127,35 +127,34 @@ namespace VNLib.Utils.Cryptography.Noscrypt // Error code are only 8 bits, if an argument error occured, the // argument number will be in the next upper 8 bits - byte errorCode = (byte)(asPositive & 0xFF); + NCErrorCodes errorCode = (NCErrorCodes)(asPositive & 0xFF); byte argNumber = (byte)((asPositive >> 8) & 0xFF); switch (errorCode) { - case E_NULL_PTR: + case NCErrorCodes.E_NULL_PTR: RaiseNullArgExceptionForArgumentNumber(argNumber); break; - case E_INVALID_ARG: + case NCErrorCodes.E_INVALID_ARG: RaiseArgExceptionForArgumentNumber(argNumber); break; - case E_ARGUMENT_OUT_OF_RANGE: + case NCErrorCodes.E_ARGUMENT_OUT_OF_RANGE: RaiseOORExceptionForArgumentNumber(argNumber); break; - case E_INVALID_CTX: + case NCErrorCodes.E_INVALID_CTX: throw new InvalidOperationException("The library context object is null or invalid"); - case E_OPERATION_FAILED: + case NCErrorCodes.E_OPERATION_FAILED: RaiseOperationFailedException(raiseOnFailure); break; - case E_VERSION_NOT_SUPPORTED: + case NCErrorCodes.E_VERSION_NOT_SUPPORTED: throw new NotSupportedException("The requested version is not supported"); default: if(raiseOnFailure) { - throw new InvalidOperationException($"The operation failed for an unknown reason, code: {errorCode:x}"); + throw new InvalidOperationException($"The operation failed with error, code: {errorCode} for arugment {argNumber:x}"); } break; - } } -- cgit