OSDN Git Service

投稿サービスのエラー処理を微調整
authorspx <spx268@gmail.com>
Wed, 1 Jul 2015 14:09:01 +0000 (23:09 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 4 Jul 2015 03:11:23 +0000 (12:11 +0900)
OpenTween/Connection/Imgur.cs
OpenTween/Connection/Mobypicture.cs
OpenTween/Connection/TwipplePhoto.cs
OpenTween/Connection/TwitterPhoto.cs
OpenTween/Connection/imgly.cs
OpenTween/Connection/yfrog.cs

index 6f9b2a5..37b698d 100644 (file)
@@ -95,6 +95,9 @@ namespace OpenTween.Connection
 
         public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems)
         {
+            if (mediaItems == null)
+                throw new ArgumentNullException("mediaItems");
+
             if (mediaItems.Length != 1)
                 throw new ArgumentOutOfRangeException("mediaItems");
 
@@ -104,7 +107,7 @@ namespace OpenTween.Connection
                 throw new NotImplementedException();
 
             if (!item.Exists)
-                throw new ArgumentException("File isn't exists.", "mediaItems[0]");
+                throw new ArgumentException("Err:Media not found.");
 
             XDocument xml;
             try
index 5ba48c1..524feb4 100644 (file)
@@ -124,13 +124,19 @@ namespace OpenTween.Connection
 
         public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems)
         {
+            if (mediaItems == null)
+                throw new ArgumentNullException("mediaItems");
+
             if (mediaItems.Length != 1)
                 throw new ArgumentOutOfRangeException("mediaItems");
 
             var item = mediaItems[0];
 
+            if (item == null)
+                throw new ArgumentException("Err:Media not specified.");
+
             if (!item.Exists)
-                throw new ArgumentException("Err:File isn't exists.", "filePaths[0]");
+                throw new ArgumentException("Err:Media not found.");
 
             var xml = await this.mobypictureApi.UploadFileAsync(item, text)
                 .ConfigureAwait(false);
index ee27035..5415ca7 100644 (file)
@@ -104,13 +104,19 @@ namespace OpenTween.Connection
 
         public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems)
         {
+            if (mediaItems == null)
+                throw new ArgumentNullException("mediaItems");
+
             if (mediaItems.Length != 1)
                 throw new ArgumentOutOfRangeException("mediaItems");
 
             var item = mediaItems[0];
 
+            if (item == null)
+                throw new ArgumentException("Err:Media not specified.");
+
             if (!item.Exists)
-                throw new ArgumentException("Err:File isn't exists.", "filePaths[0]");
+                throw new ArgumentException("Err:Media not found.");
 
             var xml = await this.twippleApi.UploadFileAsync(item)
                 .ConfigureAwait(false);
index 63e1046..17c7264 100644 (file)
@@ -78,16 +78,19 @@ namespace OpenTween.Connection
 
         public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems)
         {
-            if (mediaItems == null || mediaItems.Length == 0)
-                throw new ArgumentException("Err:Media isn't specified.", "mediaItems");
+            if (mediaItems == null)
+                throw new ArgumentNullException("mediaItems");
+
+            if (mediaItems.Length == 0)
+                throw new ArgumentException("Err:Media not specified.");
 
             foreach (var item in mediaItems)
             {
                 if (item == null)
-                    throw new ArgumentException("Err:Media isn't specified.", "mediaItems");
+                    throw new ArgumentException("Err:Media not specified.");
 
                 if (!item.Exists)
-                    throw new ArgumentException("Err:File isn't exists.", "mediaItems");
+                    throw new ArgumentException("Err:Media not found.");
             }
 
             await Task.Run(() =>
index 5ae8f8d..79a1d49 100644 (file)
@@ -87,13 +87,19 @@ namespace OpenTween.Connection
 
         public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems)
         {
+            if (mediaItems == null)
+                throw new ArgumentNullException("mediaItems");
+
             if (mediaItems.Length != 1)
                 throw new ArgumentOutOfRangeException("mediaItems");
 
             var item = mediaItems[0];
 
+            if (item == null)
+                throw new ArgumentException("Err:Media not specified.");
+
             if (!item.Exists)
-                throw new ArgumentException("Err:File isn't exists.", "filePaths[0]");
+                throw new ArgumentException("Err:Media not found.");
 
             var xml = await this.imglyApi.UploadFileAsync(item, text)
                 .ConfigureAwait(false);
index 9c766ae..af22d5d 100644 (file)
@@ -87,13 +87,19 @@ namespace OpenTween.Connection
 
         public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems)
         {
+            if (mediaItems == null)
+                throw new ArgumentNullException("mediaItems");
+
             if (mediaItems.Length != 1)
                 throw new ArgumentOutOfRangeException("mediaItems");
 
             var item = mediaItems[0];
 
+            if (item == null)
+                throw new ArgumentException("Err:Media not specified.");
+
             if (!item.Exists)
-                throw new ArgumentException("Err:File isn't exists.", "filePaths[0]");
+                throw new ArgumentException("Err:Media not found.");
 
             var xml = await this.yfrogApi.UploadFileAsync(item, text)
                 .ConfigureAwait(false);