dev
修訂 | 3ca44dd8a7ae4a953ccc8cff34d130cd93e4b5c3 (tree) |
---|---|
時間 | 2013-11-07 00:05:43 |
作者 | Kimura Youichi <kim.upsilon@bucy...> |
Commiter | Kimura Youichi |
プロフィール画像の読み込みに係わる例外処理を修正
@@ -112,20 +112,16 @@ namespace OpenTween | ||
112 | 112 | { |
113 | 113 | var imageTask = client.DownloadDataAsync(new Uri(address), cancelToken).ContinueWith(t => |
114 | 114 | { |
115 | - if (t.Exception != null) | |
115 | + if (t.IsFaulted) | |
116 | + { | |
116 | 117 | t.Exception.Handle(e => e is WebException); |
118 | + return null; | |
119 | + } | |
117 | 120 | |
118 | 121 | if (t.Status != TaskStatus.RanToCompletion) |
119 | 122 | return null; |
120 | 123 | |
121 | - try | |
122 | - { | |
123 | - return MemoryImage.CopyFromBytes(t.Result); | |
124 | - } | |
125 | - catch (InvalidImageException) // 画像形式が不正 | |
126 | - { | |
127 | - return null; | |
128 | - } | |
124 | + return MemoryImage.CopyFromBytes(t.Result); | |
129 | 125 | }, cancelToken); |
130 | 126 | |
131 | 127 | this.innerDictionary[address] = imageTask; |
@@ -62,9 +62,13 @@ namespace OpenTween | ||
62 | 62 | { |
63 | 63 | return this.imageCache.DownloadImageAsync(this.imageUrl, force).ContinueWith(t => |
64 | 64 | { |
65 | - var image = t.Result; | |
65 | + if (t.IsFaulted) | |
66 | + { | |
67 | + t.Exception.Handle(x => x is InvalidImageException); | |
68 | + return; | |
69 | + } | |
66 | 70 | |
67 | - if (image == null) return; | |
71 | + var image = t.Result; | |
68 | 72 | |
69 | 73 | this._ImageReference.Target = image; |
70 | 74 |
@@ -84,7 +88,7 @@ namespace OpenTween | ||
84 | 88 | } |
85 | 89 | })); |
86 | 90 | } |
87 | - }, TaskContinuationOptions.OnlyOnRanToCompletion); | |
91 | + }); | |
88 | 92 | } |
89 | 93 | |
90 | 94 | public MemoryImage Image |