Files
hcs/Hcs.Client/GostCryptography/ExceptionUtility.cs
HOME-LAPTOP\kshkulev 33ab055b43 Add project
Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
2025-08-12 11:21:10 +09:00

49 lines
2.0 KiB
C#

using System;
using System.Security.Cryptography;
namespace GostCryptography
{
static class ExceptionUtility
{
public static ArgumentException Argument(string argument, string message = null, params object[] messageParameters)
{
return new ArgumentException(FormatErrorMessage(message, messageParameters), argument);
}
public static ArgumentNullException ArgumentNull(string argument, string message = null, params object[] messageParameters)
{
return new ArgumentNullException(argument, FormatErrorMessage(message, messageParameters));
}
public static ArgumentOutOfRangeException ArgumentOutOfRange(string argument, string message = null, params object[] messageParameters)
{
return new ArgumentOutOfRangeException(argument, FormatErrorMessage(message, messageParameters));
}
public static NotSupportedException NotSupported(string message = null, params object[] messageParameters)
{
return new NotSupportedException(FormatErrorMessage(message, messageParameters));
}
public static CryptographicException CryptographicException(int nativeError)
{
return new CryptographicException(nativeError);
}
public static CryptographicException CryptographicException(string message = null, params object[] messageParameters)
{
return new CryptographicException(FormatErrorMessage(message, messageParameters));
}
public static CryptographicException CryptographicException(Exception innerException, string message = null, params object[] messageParameters)
{
return new CryptographicException(FormatErrorMessage(message, messageParameters), innerException);
}
private static string FormatErrorMessage(string message, params object[] messageParameters)
{
return (message != null && messageParameters != null) ? string.Format(message, messageParameters) : message;
}
}
}