JJ.Framework.Exceptions 1.5.6877.41327

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package JJ.Framework.Exceptions --version 1.5.6877.41327
NuGet\Install-Package JJ.Framework.Exceptions -Version 1.5.6877.41327
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JJ.Framework.Exceptions" Version="1.5.6877.41327" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JJ.Framework.Exceptions --version 1.5.6877.41327
#r "nuget: JJ.Framework.Exceptions, 1.5.6877.41327"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on JJ.Framework.Exceptions:

Package Downloads
JJ.Framework.Xml The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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 6,649 10/31/2018
1.4.6873.32508 4,465 10/26/2018
1.4.6873.32106 4,103 10/26/2018
1.4.6862.40443 4,848 10/15/2018
1.3.6681.33422 5,749 4/17/2018
1.2.6640.39175 4,483 3/7/2018
1.1.0.31224 5,023 3/4/2018
1.0.6636.31311 4,317 3/3/2018
1.0.6636.153 5,354 3/2/2018