nicko 2004/06/06 17:57:31
Modified: src/Util SystemInfo.cs
Log:
Make catches more specific where possible. Added method
CreateArgumentOutOfRangeException
Revision Changes Path
1.5 +33 -2 logging-log4net/src/Util/SystemInfo.cs
Index: SystemInfo.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Util/SystemInfo.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SystemInfo.cs 28 May 2004 21:30:02 -0000 1.4
+++ SystemInfo.cs 7 Jun 2004 00:57:31 -0000 1.5
@@ -166,7 +166,10 @@
// Lookup the host name
s_hostName =
System.Net.Dns.GetHostName();
}
- catch
+
catch(System.Net.Sockets.SocketException)
+ {
+ }
+ catch(System.Security.SecurityException)
{
// We may get a security
exception looking up the hostname
// You must have Unrestricted
DnsPermission to access resource
@@ -181,7 +184,10 @@
s_hostName =
Environment.MachineName;
#endif
}
- catch
+ catch(InvalidOperationException)
+ {
+ }
+
catch(System.Security.SecurityException)
{
// We may get a
security exception looking up the machine name
// You must have
Unrestricted EnvironmentPermission to access resource
@@ -520,6 +526,31 @@
return PocketGuid.NewGuid();
#else
return Guid.NewGuid();
+#endif
+ }
+
+ /// <summary>
+ /// Create a new instance of the <see
cref="ArgumentOutOfRangeException"/> class
+ /// with a specified error message, the parameter name, and the
value
+ /// of the argument.
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter that
caused the exception</param>
+ /// <param name="actualValue">The value of the argument that
causes this exception</param>
+ /// <param name="message">The message that describes the
error</param>
+ /// <returns>the ArgumentOutOfRangeException object</returns>
+ /// <remarks>
+ /// <para>
+ /// The Compact Framework does not support the 3 parameter
constructor for the
+ /// <see cref="ArgumentOutOfRangeException"/> type. This method
provides an
+ /// implementation that works for all platforms.
+ /// </para>
+ /// </remarks>
+ public static ArgumentOutOfRangeException
CreateArgumentOutOfRangeException(string parameterName, object actualValue,
string message)
+ {
+#if NETCF
+ return new ArgumentOutOfRangeException(message + "
param: " + parameterName + " value: " + actualValue);
+#else
+ return new ArgumentOutOfRangeException(parameterName,
actualValue, message);
#endif
}