1 #Region "Microsoft.VisualBasic::94ae4e0b491c5d095a6e2a53002a395b, Microsoft.VisualBasic.Core\ApplicationServices\Debugger\VisualBasicAppException.vb"
2
3     ' Author:
4     
5     '       asuka (amethyst.asuka@gcmodeller.org)
6     '       xie (genetics@smrucc.org)
7     '       xieguigang (xie.guigang@live.com)
8     
9     ' Copyright (c) 2018 GPL3 Licensed
10     
11     
12     ' GNU GENERAL PUBLIC LICENSE (GPL3)
13     
14     
15     ' This program is free software: you can redistribute it and/or modify
16     ' it under the terms of the GNU General Public License as published by
17     ' the Free Software Foundation, either version 3 of the License, or
18     ' (at your option) any later version.
19     
20     ' This program is distributed in the hope that it will be useful,
21     ' but WITHOUT ANY WARRANTY; without even the implied warranty of
22     ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     ' GNU General Public License for more details.
24     
25     ' You should have received a copy of the GNU General Public License
26     ' along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28
29
30     ' /********************************************************************************/
31
32     ' Summaries:
33
34     '     Class VisualBasicAppException
35     
36     '         Properties: args, Environment, System
37     
38     '         Constructor: (+1 OverloadsSub New
39     '         Function: Creates
40     
41     '     Module ExceptionExtensions
42     
43     
44     '         Delegate Sub
45     
46     '             Function: Fail
47     
48     
49     
50     ' /********************************************************************************/
51
52 #End Region
53
54 Imports System.Runtime.CompilerServices
55
56 Namespace ApplicationServices.Debugging
57
58     ''' <summary>
59     ''' VisualBasic application exception wrapper
60     ''' </summary>
61     Public Class VisualBasicAppException : Inherits Exception
62
63         ''' <summary>
64         ''' The CLI arguments string
65         ''' </summary>
66         ''' <returns></returns>
67         Public Property args As String
68         ''' <summary>
69         ''' The internal App environment variables
70         ''' </summary>
71         ''' <returns></returns>
72         Public Property Environment As Dictionary(Of StringString)
73         ''' <summary>
74         ''' The system version information
75         ''' </summary>
76         ''' <returns></returns>
77         Public Property System As Dictionary(Of StringString)
78
79         ''' <summary>
80         ''' <see cref="Exception"/> inner wrapper
81         ''' </summary>
82         ''' <param name="ex">The exception details</param>
83         ''' <param name="calls">Method name where occurs this exception.</param>
84         Sub New(ex As Exception, calls As String)
85             MyBase.New("@" & calls, ex)
86         End Sub
87
88         Public Shared Function Creates(msg As String, calls As StringAs VisualBasicAppException
89             Return New VisualBasicAppException(New Exception(msg), calls)
90         End Function
91     End Class
92
93     Public Module ExceptionExtensions
94
95         ''' <summary>
96         ''' 处理错误的工作逻辑的抽象接口
97         ''' </summary>
98         ''' <param name="ex">Socket的内部错误信息</param>
99         ''' <remarks></remarks>
100         Public Delegate Sub ExceptionHandler(ex As Exception)
101
102         ''' <summary>
103         ''' Just throw exception, but the exception contains more details information for the debugging
104         ''' </summary>
105         ''' <param name="msg$"></param>
106         ''' <returns></returns>
107         Public Function Fail(msg$, <CallerMemberName> Optional caller$ = ""As VisualBasicAppException
108             Return VisualBasicAppException.Creates(msg, caller)
109         End Function
110     End Module
111 End Namespace