OSDN Git Service

na-get-lib,アップデート処理新方式(NaGetUpdate2)におけるエラー処理を修正。
authorttp <ttp@users.sourceforge.jp>
Sat, 7 May 2011 02:42:08 +0000 (11:42 +0900)
committerttp <ttp@users.sourceforge.jp>
Sat, 7 May 2011 02:42:08 +0000 (11:42 +0900)
all-get/Main.cs
na-get-lib/NaGet.SubCommands.SubTask/DownloadSubTask.cs
na-get-lib/NaGet.SubCommands/NaGetUpdate2.cs

index 1091025..a3f210d 100644 (file)
@@ -131,12 +131,21 @@ namespace AllGet
                                        }\r
                                        Console.CursorLeft = origPosX;\r
                                        \r
-                                       if (e.Type == TaskEventType.PING) {\r
-                                               int origPos = Console.CursorLeft;\r
-                                               Console.Write(e.TaskMessage);\r
-                                               Console.CursorLeft = origPos;\r
-                                       } else {\r
-                                               Console.WriteLine(e.TaskMessage);\r
+                                       switch (e.Type) {\r
+                                               case TaskEventType.PING:\r
+                                                       {\r
+                                                               int origPos = Console.CursorLeft;\r
+                                                               Console.Write(e.TaskMessage);\r
+                                                               Console.CursorLeft = origPos;\r
+                                                       }\r
+                                                       break;\r
+                                               case TaskEventType.WARNING:\r
+                                               case TaskEventType.ERROR:\r
+                                                       Console.WriteLine("  [Error]" + e.TaskMessage);\r
+                                                       break;\r
+                                               default:\r
+                                                       Console.WriteLine(e.TaskMessage);\r
+                                                       break;\r
                                        }\r
                                }\r
                        };\r
index 69d0019..2746786 100644 (file)
@@ -143,6 +143,15 @@ namespace NaGet.SubCommands.SubTask
                                runHandleCancelTrigger();
                                
                                runPostprocess();
+                               
+                               RaiseTaskSetEvent(TaskEventType.COMPLETED, "ダウンロード終了", 100);
+                       } catch (System.Net.WebException e) {
+                               if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {
+                                       RaiseTaskSetEvent(TaskEventType.WARNING, "ネットワークに接続されていません。", -1);
+                               } else {
+                                       RaiseTaskSetEvent(TaskEventType.WARNING, "ネットワークに接続できませんでした。ネットワークが切断されているか、ファイアウォールによって遮断された可能性があります。", -1);
+                               }
+                               throw new System.Net.WebException(e.Message, e);
                        } finally {
                                runReleaseResponse();
                                
@@ -150,7 +159,6 @@ namespace NaGet.SubCommands.SubTask
                                        NotifyCancelled();
                                } else {
                                        NotifyCompleted();
-                                       RaiseTaskSetEvent(TaskEventType.COMPLETED, "ダウンロード終了", 100);
                                }
                        }
                }
index 83048bc..59856e2 100644 (file)
@@ -63,6 +63,8 @@ namespace NaGet.SubCommands
                public override void Run()
                {
                        NotifyStarted();
+                       RaiseTaskSetEvent(TaskEventType.STARTED, string.Empty);
+                       
                        try {
                                while (hasMoreSubTask) {
                                        RaiseTaskSetEvent(TaskEventType.STARTED_SUBTASK, currentSubTaskName);
@@ -71,13 +73,20 @@ namespace NaGet.SubCommands
                                        
                                        NotifyGoToNextSubTask();
                                }
+                       } catch (TaskCanceledException) {
+                               cancelCalled = true;
+                       } catch (Exception e) {
+                               RaiseTaskSetEvent(TaskEventType.ERROR, e.Message);
                        } finally {
                                runDeleteTempFiles();
-                               if (cancelCalled) {
-                                       NotifyCancelled();
-                               } else {
-                                       NotifyCompleted();
-                               }
+                       }
+                       
+                       if (cancelCalled) {
+                               NotifyCancelled();
+                               RaiseTaskSetEvent(TaskEventType.CANCELED, string.Empty);
+                       } else {
+                               NotifyCompleted();
+                               RaiseTaskSetEvent(TaskEventType.COMPLETED, string.Empty);
                        }
                }