Class Exceptions
- Namespace
- SunamoExceptions
- Assembly
- SunamoExceptions.dll
Provides static methods for generating exception messages with consistent formatting.
public sealed class Exceptions
- Inheritance
-
Exceptions
- Inherited Members
- Extension Methods
Methods
AddParams()
Adds additional parameter information to exception messages.
public static string AddParams()
Returns
- string
A formatted string containing additional parameter information.
AnyElementIsNullOrEmpty(string, string, IEnumerable<int>)
Creates an error message when collection elements are null or empty.
public static string? AnyElementIsNullOrEmpty(string before, string nameOfCollection, IEnumerable<int> nulled)
Parameters
beforestringThe prefix for the error message.
nameOfCollectionstringThe name of the collection.
nulledIEnumerable<int>Indexes of null/empty elements.
Returns
- string
An error message.
ArgumentOutOfRangeException(string, string, string)
Creates an ArgumentOutOfRangeException error message.
public static string? ArgumentOutOfRangeException(string before, string paramName, string message)
Parameters
beforestringThe prefix for the error message.
paramNamestringThe name of the parameter.
messagestringAdditional information.
Returns
- string
An error message.
ArrayElementContainsUnallowedStrings(string, string, int, string, params string[])
Checks if an array element contains unallowed strings.
public static string? ArrayElementContainsUnallowedStrings(string before, string arrayName, int dex, string valueElement, params string[] unallowedStrings)
Parameters
beforestringThe prefix for the error message.
arrayNamestringThe array name.
dexintThe index of the element.
valueElementstringThe element value.
unallowedStringsstring[]The unallowed strings to check for.
Returns
- string
An error message if unallowed strings are found, otherwise null.
BadFormatOfElementInList(string, object, string, Func<object, string>)
Creates an error message for a badly formatted element in a list.
public static string? BadFormatOfElementInList(string before, object elVal, string listName, Func<object, string> SH_NullToStringOrDefault)
Parameters
beforestringThe prefix for the error message.
elValobjectThe element value.
listNamestringThe name of the list.
SH_NullToStringOrDefaultFunc<object, string>Function to convert null to string.
Returns
- string
An error message.
BadMappedXaml(string, string, string)
Creates an error message for badly mapped XAML.
public static string? BadMappedXaml(string before, string nameControl, string additionalInfo)
Parameters
beforestringThe prefix for the error message.
nameControlstringThe name of the control.
additionalInfostringAdditional information about the error.
Returns
- string
An error message.
CannotCreateDateTime(string, int, int, int, int, int, int, Exception)
Creates an error message when DateTime cannot be created with the specified parameters.
public static string? CannotCreateDateTime(string before, int year, int month, int day, int hour, int minute, int seconds, Exception ex)
Parameters
beforestringThe prefix for the error message.
yearintThe year value.
monthintThe month value.
dayintThe day value.
hourintThe hour value.
minuteintThe minute value.
secondsintThe seconds value.
exExceptionThe exception that occurred.
Returns
- string
An error message.
CannotMoveFolder(string, string, string, Exception)
Creates an error message when a folder cannot be moved.
public static string? CannotMoveFolder(string before, string sourcePath, string destinationPath, Exception ex)
Parameters
beforestringThe prefix for the error message.
sourcePathstringThe source folder path.
destinationPathstringThe destination folder path.
exExceptionThe exception that occurred.
Returns
- string
An error message.
CheckBackSlashEnd(string, string)
Checks if a string ends with a backslash.
public static string? CheckBackSlashEnd(string before, string r)
Parameters
Returns
- string
An error message if the string doesn't end with a backslash, otherwise null.
CheckBackslashEnd(string, string)
Checks if a string ends with a backslash.
public static string? CheckBackslashEnd(string before, string path)
Parameters
Returns
- string
An error message if the string doesn't end with a backslash, otherwise null.
CheckBefore(string)
Checks and formats the 'before' parameter, adding a colon separator if not empty.
public static string CheckBefore(string before)
Parameters
beforestringThe prefix text to check and format.
Returns
- string
Empty string if
beforeis null or whitespace, otherwisebeforewith ": " appended.
Custom(string, string)
Creates a custom error message.
public static string? Custom(string before, string message)
Parameters
Returns
- string
An error message.
DifferentCountInLists(string, string, int, string, int)
Checks if two collections have different element counts.
public static string? DifferentCountInLists(string before, string namefc, int countfc, string namesc, int countsc)
Parameters
beforestringThe prefix for the error message.
namefcstringThe name of the first collection.
countfcintThe count of the first collection.
namescstringThe name of the second collection.
countscintThe count of the second collection.
Returns
- string
An error message if counts differ, otherwise null.
DirectoryExists(string, string)
Checks if a directory exists.
public static string? DirectoryExists(string before, string fulLPath)
Parameters
Returns
- string
Null if directory exists, otherwise an error message.
DirectoryWasntFound(string, string)
Checks if a directory exists.
public static string? DirectoryWasntFound(string before, string directory)
Parameters
Returns
- string
An error message if the directory doesn't exist, otherwise null.
DivideByZero(string)
Creates an error message for division by zero.
public static string? DivideByZero(string before)
Parameters
beforestringThe prefix for the error message.
Returns
- string
An error message.
DoesntHaveRequiredType(string, string)
Creates an error message when a variable doesn't have the required type.
public static string? DoesntHaveRequiredType(string before, string variableName)
Parameters
Returns
- string
An error message.
DuplicatedElements(string, string, List<string>, string)
Checks if a list contains duplicated elements.
public static string? DuplicatedElements(string before, string nameOfVariable, List<string> duplicatedElements, string message = "")
Parameters
beforestringThe prefix for the error message.
nameOfVariablestringThe variable name.
duplicatedElementsList<string>The list of duplicated elements.
messagestringAdditional message.
Returns
- string
An error message if duplicates are found, otherwise null.
ElementCantBeFound(string, string, string)
Creates an error message when an element cannot be found in a collection.
public static string? ElementCantBeFound(string before, string nameCollection, string element)
Parameters
beforestringThe prefix for the error message.
nameCollectionstringThe name of the collection.
elementstringThe element that cannot be found.
Returns
- string
An error message.
ElementWasntRemoved(string, string, int, int)
Checks if an element wasn't removed from a collection.
public static string? ElementWasntRemoved(string before, string detailLocation, int countBefore, int countAfter)
Parameters
beforestringThe prefix for the error message.
detailLocationstringDetails about where the removal was attempted.
countBeforeintThe count before removal.
countAfterintThe count after removal.
Returns
- string
An error message if the element wasn't removed, otherwise null.
ExcAsArg(string, Exception, string)
Creates an error message from an exception with an additional message.
public static string? ExcAsArg(string before, Exception ex, string message)
Parameters
beforestringThe prefix for the error message.
exExceptionThe exception.
messagestringAdditional message.
Returns
- string
An error message.
FileAlreadyExists(string, string)
Checks if a file already exists.
public static string? FileAlreadyExists(string before, string path)
Parameters
Returns
- string
An error message if the file exists, otherwise null.
FileExists(string, string)
Creates an error message when a file doesn't exist.
public static string? FileExists(string before, string fulLPath)
Parameters
Returns
- string
An error message.
FileHasExtensionNotParseAbleToImageFormat(string, string)
Creates an error message for files with extensions that cannot be parsed to image format.
public static string? FileHasExtensionNotParseAbleToImageFormat(string before, string fnOri)
Parameters
Returns
- string
An error message.
FileSystemException(string, Exception)
Creates an error message from a file system exception.
public static string? FileSystemException(string value, Exception ex)
Parameters
Returns
- string
An error message if exception is not null, otherwise null.
FileWasntFoundInDirectory(string, string)
Creates an error message when a file wasn't found in a directory.
public static string? FileWasntFoundInDirectory(string before, string path)
Parameters
Returns
- string
An error message.
FirstLetterIsNotUpper(string, string)
Checks if the first letter of a string is not uppercase.
public static string? FirstLetterIsNotUpper(string before, string text)
Parameters
Returns
- string
An error message if the first letter is not uppercase, otherwise null.
FolderCannotBeDeleted(string, string, Exception)
Creates an error message when a folder cannot be deleted.
public static string? FolderCannotBeDeleted(string before, string folder, Exception ex)
Parameters
beforestringThe prefix for the error message.
folderstringThe folder path.
exExceptionThe exception that occurred.
Returns
- string
An error message.
FolderCantBeRemoved(string, string)
Creates an error message when a folder can't be removed.
public static string? FolderCantBeRemoved(string before, string folder)
Parameters
Returns
- string
An error message.
FolderIsNotEmpty(string, string, string)
Creates an error message indicating that a folder is not empty.
public static string? FolderIsNotEmpty(string before, string variableName, string path)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe name of the variable.
pathstringThe path to the folder.
Returns
- string
An error message.
FunctionalityDenied(string, string)
Creates an error message when functionality is denied.
public static string? FunctionalityDenied(string before, string functionalityName)
Parameters
beforestringThe prefix for the error message.
functionalityNamestringThe name of the denied functionality.
Returns
- string
An error message.
HasNotIndex<T>(string, IEnumerable<T>, string, int)
Checks if a list has enough elements to access the specified index.
public static string? HasNotIndex<T>(string before, IEnumerable<T> list, string listName, int maxRequiredIndex)
Parameters
beforestringThe prefix for the error message.
listIEnumerable<T>The list to check.
listNamestringThe name of the list for the error message.
maxRequiredIndexintThe maximum index that must be accessible.
Returns
- string
An error message if the list doesn't have enough elements, otherwise null.
Type Parameters
TThe type of elements in the list.
HasNotKeyDictionary<Key, Value>(string, string, IDictionary<Key, Value>, Key)
Checks if a dictionary does not contain a specified key.
public static string? HasNotKeyDictionary<Key, Value>(string before, string nameDict, IDictionary<Key, Value> qsDict, Key remains)
Parameters
beforestringThe prefix for the error message.
nameDictstringThe name of the dictionary.
qsDictIDictionary<Key, Value>The dictionary to check.
remainsKeyThe key to check for.
Returns
- string
An error message if the key is not found, otherwise null.
Type Parameters
KeyThe type of the dictionary key.
ValueThe type of the dictionary value.
HasOddNumberOfElements(string, string, ICollection)
Checks if a list has an odd number of elements.
public static string? HasOddNumberOfElements(string before, string listName, ICollection list)
Parameters
beforestringThe prefix for the error message.
listNamestringThe name of the list.
listICollectionThe list to check.
Returns
- string
An error message if the list has an odd number of elements, otherwise null.
HaveAllInnerSameCount(string, List<List<string>>)
Checks if all inner lists have the same count.
public static string? HaveAllInnerSameCount(string before, List<List<string>> elements)
Parameters
beforestringThe prefix for the error message.
elementsList<List<string>>The list of lists to check.
Returns
- string
An error message if counts differ, otherwise null.
InvalidExactlyLength(string, string, int, int)
Validates that a variable has the exact required length.
public static string? InvalidExactlyLength(string before, string variableName, int length, int requiredLenght)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe name of the variable.
lengthintThe actual length.
requiredLenghtintThe required length.
Returns
- string
An error message if lengths don't match, otherwise null.
InvalidParameter(string, string, string)
Checks if a parameter is URL encoded when it shouldn't be.
public static string? InvalidParameter(string before, string valueVar, string nameVar)
Parameters
beforestringThe prefix for the error message.
valueVarstringThe variable value.
nameVarstringThe variable name.
Returns
- string
An error message if the parameter is URL encoded, otherwise null.
IsEmpty(string, IEnumerable, string, string)
Checks if a collection is empty.
public static string? IsEmpty(string before, IEnumerable folders, string colName, string additionalMessage = "")
Parameters
beforestringThe prefix for the error message.
foldersIEnumerableThe collection to check.
colNamestringThe name of the collection.
additionalMessagestringAdditional message to append.
Returns
- string
An error message if the collection is empty, otherwise null.
IsNotAllowed(string, string)
Creates an error message indicating that something is not allowed.
public static string? IsNotAllowed(string before, string what)
Parameters
Returns
- string
An error message.
IsNotNull(string, string, object)
Checks if a variable is not null when it should be.
public static string? IsNotNull(string before, string variableName, object variable)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe variable name.
variableobjectThe variable to check.
Returns
- string
An error message if the variable is not null, otherwise null.
IsNotPositiveNumber(string, string, int?)
Checks if a value is not a positive number.
public static string? IsNotPositiveNumber(string before, string nameOfVariable, int? n)
Parameters
beforestringThe prefix for the error message.
nameOfVariablestringThe variable name.
nint?The value to check.
Returns
- string
An error message if the value is not a positive number, otherwise null.
IsNotTheSame<T>(string, string, T, string, T)
Checks if two values are not equal and returns an error message if they differ.
public static string? IsNotTheSame<T>(string before, string name1, T value1, string name2, T value2)
Parameters
beforestringThe prefix for the error message.
name1stringThe name of the first value.
value1TThe first value to compare.
name2stringThe name of the second value.
value2TThe second value to compare.
Returns
- string
An error message if values differ, otherwise null.
Type Parameters
TThe type of values to compare.
IsNotWindowsPathFormat(string, string, string, bool, Func<string, bool>)
Checks if a string is not in Windows path format.
public static string? IsNotWindowsPathFormat(string before, string argName, string argValue, bool raiseIsNotWindowsPathFormat, Func<string, bool> SunamoFileSystem_IsWindowsPathFormat)
Parameters
beforestringThe prefix for the error message.
argNamestringThe argument name.
argValuestringThe argument value to check.
raiseIsNotWindowsPathFormatboolWhether to raise the check.
SunamoFileSystem_IsWindowsPathFormatFunc<string, bool>Function to check Windows path format.
Returns
- string
An error message if the format is invalid, otherwise null.
IsNull(string, string, object?)
Checks if a variable is null.
public static string? IsNull(string before, string variableName, object? variable)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe variable name.
variableobjectThe variable to check.
Returns
- string
An error message if the variable is null, otherwise null.
IsNullOrWhitespace(string, string, string, bool)
Checks if a string argument is null, empty, or whitespace.
public static string? IsNullOrWhitespace(string before, string argName, string argValue, bool notAllowOnlyWhitespace)
Parameters
beforestringThe prefix for the error message.
argNamestringThe name of the argument.
argValuestringThe value to check.
notAllowOnlyWhitespaceboolIf true, whitespace-only strings are also considered invalid.
Returns
- string
An error message if validation fails, otherwise null.
IsTheSame(string, string, string)
Creates an error message when two values are the same but should differ.
public static string? IsTheSame(string before, string fst, string sec)
Parameters
beforestringThe prefix for the error message.
fststringThe first value name.
secstringThe second value name.
Returns
- string
An error message.
IsWhitespaceOrNull(string, string, object)
Checks if a value is whitespace or null.
public static string? IsWhitespaceOrNull(string before, string variable, object data)
Parameters
beforestringThe prefix for the error message.
variablestringThe variable name.
dataobjectThe data to check.
Returns
- string
An error message if the value is whitespace or null, otherwise null.
IsWindowsPathFormat(string, string, Func<string, bool>)
Checks if a string is in Windows path format when it shouldn't be.
public static string? IsWindowsPathFormat(string before, string input, Func<string, bool> isWindowsPathFormat)
Parameters
beforestringThe prefix for the error message.
inputstringThe input string to check.
isWindowsPathFormatFunc<string, bool>Function to check Windows path format.
Returns
- string
An error message if the input is a path when only a key is expected, otherwise null.
KeyAlreadyExists<T, U>(string, Dictionary<T, U>, T, string)
Checks if a key already exists in a dictionary.
public static string? KeyAlreadyExists<T, U>(string before, Dictionary<T, U> dictionary, T key, string dictionaryName) where T : notnull
Parameters
beforestringThe prefix for the error message.
dictionaryDictionary<T, U>The dictionary to check.
keyTThe key to check for.
dictionaryNamestringThe name of the dictionary.
Returns
- string
An error message if the key exists, otherwise null.
Type Parameters
TThe type of the dictionary key.
UThe type of the dictionary value.
KeyNotFound<T, U>(string, IDictionary<T, U>, string, T)
Checks if a key is not found in a dictionary.
public static string? KeyNotFound<T, U>(string before, IDictionary<T, U> en, string dictName, T key)
Parameters
beforestringThe prefix for the error message.
enIDictionary<T, U>The dictionary to check.
dictNamestringThe name of the dictionary.
keyTThe key to find.
Returns
- string
An error message if the key is not found, otherwise null.
Type Parameters
TThe type of the dictionary key.
UThe type of the dictionary value.
ListNullOrEmpty<T>(string, string, IEnumerable<T>?)
Checks if a list is null or empty.
public static string? ListNullOrEmpty<T>(string before, string variableName, IEnumerable<T>? list)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe name of the variable.
listIEnumerable<T>The list to check.
Returns
- string
An error message if the list is null or empty, otherwise null.
Type Parameters
TThe type of elements in the list.
LockedByBitLocker(string, string, Func<char, bool>)
Checks if a drive is locked by BitLocker.
public static string? LockedByBitLocker(string before, string path, Func<char, bool> IsLockedByBitLocker)
Parameters
beforestringThe prefix for the error message.
pathstringThe path to check.
IsLockedByBitLockerFunc<char, bool>Function to check if a drive is locked.
Returns
- string
An error message if the drive is locked, otherwise null.
MoreCandidates(string, IEnumerable<string>, string)
Creates an error message when there are multiple candidates.
public static string? MoreCandidates(string before, IEnumerable<string> list, string item)
Parameters
beforestringThe prefix for the error message.
listIEnumerable<string>The list of candidates.
itemstringThe item with multiple candidates.
Returns
- string
An error message.
MoreThanOneElement(string, string, int, string)
Checks if a list has more than one element.
public static string? MoreThanOneElement(string before, string listName, int count, string moreInfo = "")
Parameters
beforestringThe prefix for the error message.
listNamestringThe list name.
countintThe actual count.
moreInfostringAdditional information.
Returns
- string
An error message if the list has more than one element, otherwise null.
NameIsNotSetted(string, string, string)
Checks if a control's name is not set.
public static string? NameIsNotSetted(string before, string nameControl, string nameFromProperty)
Parameters
beforestringThe prefix for the error message.
nameControlstringThe control name.
nameFromPropertystringThe name from the property.
Returns
- string
An error message if the name is not set, otherwise null.
NoPassedFolders(string, ICollection)
Checks if no folders were passed.
public static string? NoPassedFolders(string before, ICollection folders)
Parameters
beforestringThe prefix for the error message.
foldersICollectionThe folders collection.
Returns
- string
An error message if no folders were passed, otherwise null.
NotContains(string, string, params string[])
Checks if a string does not contain required substrings.
public static string? NotContains(string before, string originalText, params string[] shouldContains)
Parameters
beforestringThe prefix for the error message.
originalTextstringThe original text to check.
shouldContainsstring[]The substrings that should be contained.
Returns
- string
An error message if any required substring is missing, otherwise null.
NotEvenNumberOfElements(string, string)
Creates an error message when a collection has an odd number of elements.
public static string? NotEvenNumberOfElements(string before, string nameOfCollection)
Parameters
Returns
- string
An error message.
NotExists(string, string)
Creates an error message when something does not exist.
public static string? NotExists(string before, string what)
Parameters
Returns
- string
An error message.
NotImplementedCase(string, object)
Creates an error message for a not implemented case.
public static string? NotImplementedCase(string before, object notImplementedName)
Parameters
beforestringThe prefix for the error message.
notImplementedNameobjectThe name or type of the not implemented case.
Returns
- string
An error message.
NotImplementedMethod(string)
Creates an error message for a method that is not implemented.
public static string? NotImplementedMethod(string before)
Parameters
beforestringThe prefix for the error message.
Returns
- string
An error message.
NotInRange(string, string, IEnumerable<string>, int, int)
Checks if a variable is within the specified range.
public static string? NotInRange(string before, string variableName, IEnumerable<string> list, int isLt, int isGt)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe name of the variable.
listIEnumerable<string>The list of items.
isLtintThe lower bound.
isGtintThe upper bound.
Returns
- string
An error message if out of range, otherwise null.
NotInt(string, string, int?)
Checks if a value is not a valid integer.
public static string? NotInt(string before, string what, int? value)
Parameters
beforestringThe prefix for the error message.
whatstringDescription of what should be an integer.
valueint?The value to check.
Returns
- string
An error message if the value is not a valid integer, otherwise null.
NotSupported(string)
Creates a generic "not supported" error message.
public static string? NotSupported(string before)
Parameters
beforestringThe prefix for the error message.
Returns
- string
An error message.
NotSupportedExtension(string, string)
Creates an error message for an unsupported file extension.
public static string? NotSupportedExtension(string before, string extension)
Parameters
Returns
- string
An error message.
NotValidXml(string, string, Exception)
Creates an error message for invalid XML.
public static string? NotValidXml(string before, string path, Exception ex)
Parameters
beforestringThe prefix for the error message.
pathstringThe path to the XML file.
exExceptionThe exception that occurred.
Returns
- string
An error message.
OnlyOneElement(string, string, ICollection)
Checks if a collection has only one element.
public static string? OnlyOneElement(string before, string colName, ICollection list)
Parameters
beforestringThe prefix for the error message.
colNamestringThe collection name.
listICollectionThe collection.
Returns
- string
An error message if the collection has only one element, otherwise null.
OutOfRange(string, string, ICollection, string, int)
Checks if an index is out of range for a collection.
public static string? OutOfRange(string before, string colName, ICollection col, string indexName, int index)
Parameters
beforestringThe prefix for the error message.
colNamestringThe collection name.
colICollectionThe collection.
indexNamestringThe index variable name.
indexintThe index value.
Returns
- string
An error message if the index is out of range, otherwise null.
PassedListInsteadOfArray<T>(string, string, IEnumerable<T>, Func<IEnumerable<T>, bool>)
Checks if a list was passed instead of an array to a params parameter.
public static string? PassedListInsteadOfArray<T>(string before, string variableName, IEnumerable<T> collection, Func<IEnumerable<T>, bool> CA_IsListStringWrappedInArray)
Parameters
beforestringThe prefix for the error message.
variableNamestringThe name of the variable.
collectionIEnumerable<T>The collection to check.
CA_IsListStringWrappedInArrayFunc<IEnumerable<T>, bool>Function to check if it's a wrapped list.
Returns
- string
An error message if a list was passed instead of an array, otherwise null.
Type Parameters
TThe type of elements.
RepeatAfterTimeXTimesFailed(string, int, int, string, int)
Creates an error message for repeated failed attempts to load a URI.
public static string? RepeatAfterTimeXTimesFailed(string before, int times, int timeoutInMs, string address, int sharedAlgorithmslastError)
Parameters
beforestringThe prefix for the error message.
timesintNumber of failed attempts.
timeoutInMsintTimeout in milliseconds.
addressstringThe URI address.
sharedAlgorithmslastErrorintThe last HTTP error code.
Returns
- string
An error message.
StartIsHigherThanEnd(string, int, int)
Checks if start value is higher than end value.
public static string? StartIsHigherThanEnd(string before, int start, int end)
Parameters
Returns
- string
An error message if start is higher than end, otherwise null.
StringContainsUnallowedSubstrings(string, string, params string[])
Checks if a string contains unallowed substrings.
public static string? StringContainsUnallowedSubstrings(string before, string input, params string[] unallowedStrings)
Parameters
beforestringThe prefix for the error message.
inputstringThe input string to check.
unallowedStringsstring[]The unallowed substrings.
Returns
- string
An error message if unallowed substrings are found, otherwise null.
TextOfExceptions(Exception)
Gets all messages from an exception and its inner exceptions.
public static string TextOfExceptions(Exception ex)
Parameters
exExceptionThe exception to extract messages from.
Returns
- string
A string containing all exception messages.
ToManyElementsInCollection(string, int, int, string)
Creates an error message when a collection has too many elements.
public static string? ToManyElementsInCollection(string before, int max, int actual, string nameCollection)
Parameters
beforestringThe prefix for the error message.
maxintMaximum allowed elements.
actualintActual number of elements.
nameCollectionstringThe name of the collection.
Returns
- string
An error message.
TypeAndMethodName(string, out string, out string)
Extracts type and method name from a stack trace line.
public static void TypeAndMethodName(string stackTraceLine, out string type, out string methodName)
Parameters
stackTraceLinestringThe stack trace line to parse.
typestringThe extracted type name.
methodNamestringThe extracted method name.
UncommentNextRows(string)
Creates an error message prompting to uncomment next rows.
public static string? UncommentNextRows(string before)
Parameters
beforestringThe prefix for the error message.
Returns
- string
An error message.
UriFormat(string, string, Func<string, bool>)
Checks if a URL is in valid URI format.
public static string? UriFormat(string before, string url, Func<string, bool> uhIsUri)
Parameters
beforestringThe prefix for the error message.
urlstringThe URL to check.
uhIsUriFunc<string, bool>Function to validate URI format.
Returns
- string
An error message if the URL format is invalid, otherwise null.
UseRlc(string)
Creates an error message indicating that RLC methods should be used instead.
public static string? UseRlc(string before)
Parameters
beforestringThe prefix for the error message.
Returns
- string
An error message.
WasAlreadyInitialized(string)
Creates an error message indicating that something was already initialized.
public static string WasAlreadyInitialized(string before)
Parameters
beforestringThe prefix for the error message.
Returns
- string
An error message.
WasNotKeysHandler(string, string, object)
Checks if an object is not an IKeysHandler.
public static string? WasNotKeysHandler(string before, string name, object keysHandler)
Parameters
beforestringThe prefix for the error message.
namestringThe name of the object.
keysHandlerobjectThe object to check.
Returns
- string
An error message if the object is not an IKeysHandler, otherwise null.
WrongCountInList(string, int, int, int)
Creates an error message for wrong element count in a list.
public static string? WrongCountInList(string before, int numberOfElementsWithoutPause, int numberOfElementsWithPause, int arrLength)
Parameters
beforestringThe prefix for the error message.
numberOfElementsWithoutPauseintExpected count without pause.
numberOfElementsWithPauseintExpected count with pause.
arrLengthintActual array length.
Returns
- string
An error message.
WrongExtension(string, string, string)
Checks if a file has the wrong extension.
public static string? WrongExtension(string before, string path, string requiredExt)
Parameters
beforestringThe prefix for the error message.
pathstringThe file path.
requiredExtstringThe required extension.
Returns
- string
An error message if the extension is wrong, otherwise null.
WrongNumberOfElements<T>(string, int, string, IEnumerable<T>)
Checks if a collection has the wrong number of elements.
public static string? WrongNumberOfElements<T>(string before, int requireElements, string nameCollection, IEnumerable<T> collection)
Parameters
beforestringThe prefix for the error message.
requireElementsintThe required number of elements.
nameCollectionstringThe name of the collection.
collectionIEnumerable<T>The collection to check.
Returns
- string
An error message if the count is wrong, otherwise null.
Type Parameters
TThe type of elements in the collection.
ZeroOrMoreThanOne(string, string, List<string>)
Checks if a list has zero or more than one element.
public static string? ZeroOrMoreThanOne(string before, string nameOfVariable, List<string> list)
Parameters
beforestringThe prefix for the error message.
nameOfVariablestringThe variable name.
listList<string>The list to check.
Returns
- string
An error message if the list has zero or more than one element, otherwise null.