JJ.Framework.Exceptions
1.5.6877.41327
Prefix Reserved
dotnet add package JJ.Framework.Exceptions --version 1.5.6877.41327
NuGet\Install-Package JJ.Framework.Exceptions -Version 1.5.6877.41327
<PackageReference Include="JJ.Framework.Exceptions" Version="1.5.6877.41327" />
paket add JJ.Framework.Exceptions --version 1.5.6877.41327
#r "nuget: JJ.Framework.Exceptions, 1.5.6877.41327"
// Install JJ.Framework.Exceptions as a Cake Addin #addin nuget:?package=JJ.Framework.Exceptions&version=1.5.6877.41327 // Install JJ.Framework.Exceptions as a Cake Tool #tool nuget:?package=JJ.Framework.Exceptions&version=1.5.6877.41327
JJ.Framework.Exceptions
Contains many exception classes for common basic errors, for instance:
- Null errors, null or white space errors, collection contains nulls, etc.
- Parsing errors, type casting errors
- Not found, not unique errors
- Greater than or equal errors and the like
- Files not found, folder already exists, etc.
There are several advantages over using these exception types.
- Error messages are clear.
- Concise syntax, without sacrificing performance.
- You can pass an expression, whose text becomes part of the message.
- Invalid value is automatically mentioned in the exception message.
- Lose no time typing and trying to come up with a good message.
For example:
throw new NullException(() => myParent.MyChildren[0].MyProperty);
Will produce an exception message:
"myParent.MyChildren[0].MyProperty is null."
This is where it surpasses the possibilities of the C# 6 nameof operator, which can only mention a name, not a whole expression.
Another example:
throw new NotFoundException<Customer>(new { customerNumber, customerType });
will produce an exception message:
"Customer with key { customerNumber = 1234, customerType = Subscriber } not found."
As such it is fit for use with any composite key you might have.
Some more examples:
throw new NotUniqueException<Product>(productNumber);
throw new ValueNotSupportedException(myCountryEnumValue);
throw new FileAlreadyExistsException("text.txt");
throw new NullOrWhiteSpaceException(nameof(myParam));
Those produce the exception messages:
Product with key A123 not unique.
Country value 'Undefined' is not supported.
File 'test.txt' already exists.
myParam is null or white space.
Here is an example with the value check in it:
if (height < 10) throw new LessThanException(() => height, 10);
This produces the exception message:
height of 2 is less than 10.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- JetBrains.Annotations (>= 2018.2.1)
- JJ.Framework.Reflection (>= 1.5.0 && < 1.6.0)
- JJ.Framework.Text (>= 1.5.0 && < 1.6.0)
- System.ValueTuple (>= 4.3.0)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on JJ.Framework.Exceptions:
Package | Downloads |
---|---|
JJ.Framework.Xml
XmlToObjectConverter converts an XmlDocument or string to an object graph. The way to map XML to classes is easier than the classic ways in .NET. XmlHelper allows you to access XML in a null-safe and multiplicity-safe way. It uses XmlDocument as the underlying .NET API. |
|
JJ.Framework.IO
CsvReader FileLock PathParser SafeFileOverwriter GetNumberedFilePath StreamToBytes BytesToStream StreamToString StringToStream StringToBytes BytesToString ReadStruct WriteStruct ClearFolder ClearFolderRecursive GetFolderSize GetFolderSizeRecursive CountFilesRecursive IsFolder IsFile FolderIsEmpty IsReadOnly IsHidden MakeReadOnly MakeWritable ShowFile HideFile ToAbsolutePath ToRelativePath PathsAreEqual AssertFileExists |
|
JJ.Framework.Collections
LINQ overloads. SelectRecursive SelectAncestors Add Remove AddRange Concat CrossJoin Distinct DistinctMany Except FirstWithClearException SingleOrDefaultWithClearException SingleWithClearException ForEach IndexOf TryGetIndexOf MinOrDefault MaxOrDefault PeekOrDefault PopOrDefault Product RemoveFirst Repeat ToHashSet ToNonUniqueDictionary TrimAll TryRemoveFirst Union Zip item.AsArray item.AsList item.AsEnumerable. Also a RedBlackTree and KeyValuePairHelper ConvertNamesAndValuesListToKeyValuePairs and ConvertNamesAndValuesListToDictionary. |
|
JJ.Framework.Testing
Helper for unit tests. Mimics the Assert class, but will display the tested expression in error messages, instead of being vague about it or laborious to program. It also offers methods to evaluate if the right exception goes off in the right spot with the right exception type and / or the right message. |
|
JJ.Framework.Mathematics
Interpolator Smooth Bezier Cubic Hermite TextPlotter NumberBases ToBase FromBase ToHex FromHex ToLetterSequence FromLetterSequence Randomizer GetRandomItem GetInt32 GetDouble GetSingle IsInRectangle GetCenter AbsoluteDistance IsPowerOf2 LogRatio RoundToSignificantDigits RoundWithStep ScaleLinearly SpeadItems SpreadIntegers SpreadDoubles. Integer variation of Pow and Log. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.5.6877.41327 | 8,013 | 10/31/2018 |
1.4.6873.32508 | 5,832 | 10/26/2018 |
1.4.6873.32106 | 5,073 | 10/26/2018 |
1.4.6862.40443 | 5,220 | 10/15/2018 |
1.3.6681.33422 | 6,930 | 4/17/2018 |
1.2.6640.39175 | 5,664 | 3/7/2018 |
1.1.0.31224 | 6,327 | 3/4/2018 |
1.0.6636.31311 | 5,421 | 3/3/2018 |
1.0.6636.153 | 6,652 | 3/2/2018 |