OSDN Git Service

Exceptionクラスを直接スローしている箇所を派生型に置き換え (CA2201)
authorKimura Youichi <kim.upsilon@bucyou.net>
Mon, 14 Jul 2014 05:17:13 +0000 (14:17 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Mon, 21 Jul 2014 06:27:09 +0000 (15:27 +0900)
http://msdn.microsoft.com/ja-jp/library/ms182338.aspx

OpenTween/Connection/HttpConnectionOAuth.cs
OpenTween/MyCommon.cs
OpenTween/NativeMethods.cs
OpenTween/Tween.cs

index cf37bce..61caee2 100644 (file)
@@ -50,6 +50,7 @@ using StringBuilder = System.Text.StringBuilder;
 using HttpRequestHeader = System.Net.HttpRequestHeader;
 using HMACSHA1 = System.Security.Cryptography.HMACSHA1;
 using Encoding = System.Text.Encoding;
+using System;
 
 namespace OpenTween
 {
@@ -280,7 +281,7 @@ namespace OpenTween
                {
                        // PIN-based flow
                        if ( string.IsNullOrEmpty( requestToken ) )
-                               throw new Exception( "Sequence error.(requestToken is blank)" );
+                               throw new InvalidOperationException( "Sequence error.(requestToken is blank)" );
 
                        // アクセストークン取得
                        string content = "";
@@ -342,8 +343,10 @@ namespace OpenTween
                public HttpStatusCode AuthenticateXAuth( Uri accessTokenUrl, string username, string password, ref string content )
                {
                        // ユーザー・パスワードチェック
-                       if ( string.IsNullOrEmpty( username ) || string.IsNullOrEmpty( password ) )
-                               throw new Exception( "Sequence error.(username or password is blank)" );
+                       if ( string.IsNullOrEmpty( username ) )
+                               throw new ArgumentException( "username is null or empty", "username" );
+            if ( string.IsNullOrEmpty( password ) )
+                throw new ArgumentException( "password is null or empty", "password" );
 
                        // xAuthの拡張パラメータ設定
                        Dictionary< string, string > parameter = new Dictionary< string, string >();
index 7f23ae4..426eedb 100644 (file)
@@ -419,9 +419,8 @@ namespace OpenTween
                     case DialogResult.No:
                         return false;
                     case DialogResult.Cancel:
-                        return IsTerminatePermission;
                     default:
-                        throw new Exception("");
+                        return IsTerminatePermission;
                 }
             }
         }
index cb928dc..6f3fb8b 100644 (file)
@@ -217,15 +217,13 @@ namespace OpenTween
                 hotkeyID = GlobalAddAtom(atomName);
                 if (hotkeyID == 0)
                 {
-                    throw new Exception("Unable to generate unique hotkey ID. Error code: " +
-                       Marshal.GetLastWin32Error().ToString());
+                    throw new Win32Exception();
                 }
 
                 // register the hotkey, throw if any error
                 if (RegisterHotKey(targetForm.Handle, hotkeyID, modifiers, hotkeyValue) == 0)
                 {
-                    throw new Exception("Unable to register hotkey. Error code: " +
-                       Marshal.GetLastWin32Error().ToString());
+                    throw new Win32Exception();
                 }
                 return hotkeyID;
             }
index 4016214..43b5fa5 100644 (file)
@@ -1178,7 +1178,8 @@ namespace OpenTween
                 {
                     tab.TabType = MyCommon.TabUsageType.UserDefined;
                 }
-                if (!AddNewTab(tab.TabName, true, tab.TabType, tab.ListInfo)) throw new Exception(Properties.Resources.TweenMain_LoadText1);
+                if (!AddNewTab(tab.TabName, true, tab.TabType, tab.ListInfo))
+                    throw new TabException(Properties.Resources.TweenMain_LoadText1);
             }
 
             this.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space";