diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2011-07-02 19:33:28 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2011-07-02 19:33:28 -0700 |
commit | f2306dd1eb03996d314927c96bbd2a9412c30c8a (patch) | |
tree | 60ca38d087c7980390f4a27906da4038677347ca /src/DotNetOpenAuth.InfoCard/InfoCardErrorUtilities.cs | |
parent | b6f7a18b949acb4346754ae47fb07424076a3cd0 (diff) | |
download | DotNetOpenAuth-f2306dd1eb03996d314927c96bbd2a9412c30c8a.zip DotNetOpenAuth-f2306dd1eb03996d314927c96bbd2a9412c30c8a.tar.gz DotNetOpenAuth-f2306dd1eb03996d314927c96bbd2a9412c30c8a.tar.bz2 |
Messaging project now compiles.
Diffstat (limited to 'src/DotNetOpenAuth.InfoCard/InfoCardErrorUtilities.cs')
-rw-r--r-- | src/DotNetOpenAuth.InfoCard/InfoCardErrorUtilities.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.InfoCard/InfoCardErrorUtilities.cs b/src/DotNetOpenAuth.InfoCard/InfoCardErrorUtilities.cs new file mode 100644 index 0000000..8d627fa --- /dev/null +++ b/src/DotNetOpenAuth.InfoCard/InfoCardErrorUtilities.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +// <copyright file="InfoCardErrorUtilities.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Diagnostics.Contracts; + using System.Globalization; + + internal static class InfoCardErrorUtilities { + /// <summary> + /// Checks a condition and throws an <see cref="InfoCard.InformationCardException"/> + /// if it evaluates to false. + /// </summary> + /// <param name="condition">The condition to check.</param> + /// <param name="errorMessage">The message to include in the exception, if created.</param> + /// <param name="args">The formatting arguments.</param> + /// <exception cref="InfoCard.InformationCardException">Thrown if <paramref name="condition"/> evaluates to <c>false</c>.</exception> + [Pure] + internal static void VerifyInfoCard(bool condition, string errorMessage, params object[] args) { + Contract.Requires<ArgumentNullException>(args != null); + Contract.Ensures(condition); + Contract.EnsuresOnThrow<InfoCard.InformationCardException>(!condition); + Contract.Assume(errorMessage != null); + if (!condition) { + errorMessage = string.Format(CultureInfo.CurrentCulture, errorMessage, args); + throw new InfoCard.InformationCardException(errorMessage); + } + } + } +} |