summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-06-02 16:57:35 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-06-02 16:57:35 -0700
commit01a526749236d80cf6d51e9a5c171211505b858c (patch)
tree845882a9eb1cf4caa39f679e3b2663a2e6d6c23c /src
parentb49a8d68f890e2e5bd95d2475f106fa98463c43a (diff)
downloadDotNetOpenAuth-01a526749236d80cf6d51e9a5c171211505b858c.zip
DotNetOpenAuth-01a526749236d80cf6d51e9a5c171211505b858c.tar.gz
DotNetOpenAuth-01a526749236d80cf6d51e9a5c171211505b858c.tar.bz2
Added ErrorUtilities.VerifyHost method.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj3
-rw-r--r--src/DotNetOpenAuth/Messaging/ErrorUtilities.cs18
-rw-r--r--src/DotNetOpenAuth/Messaging/HostErrorException.cs64
3 files changed, 84 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index bc10d44..12b68f2 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -207,6 +207,7 @@
<Compile Include="Messaging\CachedDirectWebResponse.cs" />
<Compile Include="Messaging\ChannelContract.cs" />
<Compile Include="Messaging\DirectWebRequestOptions.cs" />
+ <Compile Include="Messaging\HostErrorException.cs" />
<Compile Include="Messaging\IHttpDirectResponse.cs" />
<Compile Include="Messaging\IExtensionMessage.cs" />
<Compile Include="Messaging\IMessage.cs" />
@@ -554,4 +555,4 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\tools\DotNetOpenAuth.Versioning.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
index d5b2040..995df23 100644
--- a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
@@ -170,6 +170,24 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Throws a <see cref="HostErrorException"/> if some <paramref name="condition"/> evaluates to false.
+ /// </summary>
+ /// <param name="condition">True to do nothing; false to throw the exception.</param>
+ /// <param name="errorMessage">The error message for the exception.</param>
+ /// <param name="args">The string formatting arguments, if any.</param>
+ /// <exception cref="HostErrorException">Thrown if <paramref name="condition"/> evaluates to <c>false</c>.</exception>
+ [Pure]
+ internal static void VerifyHost(bool condition, string errorMessage, params object[] args) {
+ Contract.Requires(args != null);
+ Contract.Ensures(condition);
+ Contract.EnsuresOnThrow<ProtocolException>(!condition);
+ Contract.Assume(errorMessage != null);
+ if (!condition) {
+ throw new HostErrorException(string.Format(CultureInfo.CurrentCulture, errorMessage, args));
+ }
+ }
+
+ /// <summary>
/// Throws a <see cref="ProtocolException"/> if some <paramref name="condition"/> evaluates to false.
/// </summary>
/// <param name="condition">True to do nothing; false to throw the exception.</param>
diff --git a/src/DotNetOpenAuth/Messaging/HostErrorException.cs b/src/DotNetOpenAuth/Messaging/HostErrorException.cs
new file mode 100644
index 0000000..0ab9e51
--- /dev/null
+++ b/src/DotNetOpenAuth/Messaging/HostErrorException.cs
@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------
+// <copyright file="HostErrorException.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Messaging {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+ /// <summary>
+ /// An exception to call out a configuration or runtime failure on the part of the
+ /// (web) application that is hosting this library.
+ /// </summary>
+ /// <remarks>
+ /// <para>This exception is used rather than <see cref="ProtocolException"/> for those errors
+ /// that should never be caught because they indicate a major error in the app itself
+ /// or its configuration.</para>
+ /// <para>It is an internal exception to assist in making it uncatchable.</para>
+ /// </remarks>
+ [Serializable]
+ internal class HostErrorException : Exception {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HostErrorException"/> class.
+ /// </summary>
+ internal HostErrorException() {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HostErrorException"/> class.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ internal HostErrorException(string message)
+ : base(message) {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HostErrorException"/> class.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="inner">The inner exception.</param>
+ internal HostErrorException(string message, Exception inner)
+ : base(message, inner) {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HostErrorException"/> class.
+ /// </summary>
+ /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="info"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.Runtime.Serialization.SerializationException">
+ /// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
+ /// </exception>
+ protected HostErrorException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context) { }
+ }
+}