[hyena] SafeUri: prefer ANE over possible NRE
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] SafeUri: prefer ANE over possible NRE
- Date: Thu, 15 Sep 2011 17:31:51 +0000 (UTC)
commit 9c316ab5e38cf3b2fcbfa32581d893f2d937cd4c
Author: Andres G. Aragoneses <knocte gmail com>
Date: Thu Sep 15 18:30:02 2011 +0100
SafeUri: prefer ANE over possible NRE
ArgumentNullExceptions in the ctors are preferred over
the NullReferenceException ones because they provide
more information about the failure.
Hyena/Hyena/SafeUri.cs | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/Hyena/Hyena/SafeUri.cs b/Hyena/Hyena/SafeUri.cs
index 04535e3..0afa310 100644
--- a/Hyena/Hyena/SafeUri.cs
+++ b/Hyena/Hyena/SafeUri.cs
@@ -48,6 +48,10 @@ namespace Hyena
public SafeUri (string uri)
{
+ if (String.IsNullOrEmpty (uri)) {
+ throw new ArgumentNullException ("uri");
+ }
+
int scheme_delimit_index = uri.IndexOf ("://", StringComparison.InvariantCulture);
if (scheme_delimit_index > 0 && scheme_delimit_index <= MAX_SCHEME_LENGTH) {
this.uri = uri;
@@ -58,6 +62,10 @@ namespace Hyena
public SafeUri (string uri, bool isUri)
{
+ if (String.IsNullOrEmpty (uri)) {
+ throw new ArgumentNullException ("uri");
+ }
+
if (isUri) {
this.uri = uri;
} else {
@@ -67,6 +75,10 @@ namespace Hyena
public SafeUri (Uri uri)
{
+ if (uri == null) {
+ throw new ArgumentNullException ("uri");
+ }
+
this.uri = uri.AbsoluteUri;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]