FreeTrainの進化系を目指す
例外処理の改善と条件付リソース(オーバーライド)の基本インターフェース
| @@ -24,7 +24,8 @@ | ||
| 24 | 24 | try { |
| 25 | 25 | run(args); |
| 26 | 26 | } catch (Exception e) { |
| 27 | - UIUtil.ShowException("エラーが発生しました", e, UIInformLevel.normal); | |
| 27 | + if(UIUtil.ShowException("エラーが発生しました", e, UIInformLevel.normal)) | |
| 28 | + throw; | |
| 28 | 29 | } |
| 29 | 30 | } |
| 30 | 31 | } |
| @@ -35,7 +36,8 @@ | ||
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { |
| 38 | - UIUtil.ShowException(e.Exception.Message, e.Exception, UIInformLevel.severe); | |
| 39 | + if(UIUtil.ShowException(e.Exception.Message, e.Exception, UIInformLevel.severe)) | |
| 40 | + throw e.Exception; | |
| 39 | 41 | } |
| 40 | 42 | } |
| 41 | 43 | } |
| @@ -21,10 +21,10 @@ | ||
| 21 | 21 | /// Displays a dialog box and returns after the dialog is closed. |
| 22 | 22 | /// </summary> |
| 23 | 23 | /// <param name="owner">can be null.</param> |
| 24 | - public static bool Show( IWin32Window owner, string msg, Exception e ) { | |
| 24 | + public static DialogResult Show(IWin32Window owner, string msg, Exception e) { | |
| 25 | 25 | using( Form f = new ErrorMessageBox(msg,e) ) { |
| 26 | 26 | DialogResult res = f.ShowDialog(owner); |
| 27 | - return (res == DialogResult.Abort); | |
| 27 | + return res; | |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 |
| @@ -188,6 +188,7 @@ | ||
| 188 | 188 | // throwButton |
| 189 | 189 | // |
| 190 | 190 | this.throwButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); |
| 191 | + this.throwButton.DialogResult = System.Windows.Forms.DialogResult.Retry; | |
| 191 | 192 | this.throwButton.Location = new System.Drawing.Point(190, 220); |
| 192 | 193 | this.throwButton.Name = "throwButton"; |
| 193 | 194 | this.throwButton.Size = new System.Drawing.Size(134, 23); |
| @@ -194,7 +195,6 @@ | ||
| 194 | 195 | this.throwButton.TabIndex = 7; |
| 195 | 196 | this.throwButton.Text = "再throw(開発用)"; |
| 196 | 197 | this.throwButton.UseVisualStyleBackColor = true; |
| 197 | - this.throwButton.Click += new System.EventHandler(this.throwButton_Click); | |
| 198 | 198 | // |
| 199 | 199 | // abortButton |
| 200 | 200 | // |
| @@ -238,8 +238,7 @@ | ||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | private void throwButton_Click(object sender, EventArgs e) { |
| 241 | - Debug.WriteLine(detail.Text); | |
| 242 | - throw exception; | |
| 241 | + | |
| 243 | 242 | } |
| 244 | 243 | } |
| 245 | 244 | } |