1 | #Region "Microsoft.VisualBasic::ed67591efb5055dc6b399a7802b7baa7, Microsoft.VisualBasic.Core\CommandLine\Interpreters\View\ExceptionHandler.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 ExceptionHelp |
35 | ' |
36 | ' Properties: Debugging, Documentation, EMailLink |
37 | ' |
38 | ' Constructor: (+2 Overloads) Sub New |
39 | ' Function: ToString |
40 | ' |
41 | ' Module ExceptionHandler |
42 | ' |
43 | ' Sub: Print |
44 | ' |
45 | ' |
46 | ' /********************************************************************************/ |
47 | |
48 | #End Region |
49 | |
50 | Imports System.Reflection |
51 | Imports Microsoft.VisualBasic.ComponentModel.Settings |
52 | Imports Microsoft.VisualBasic.Serialization.JSON |
53 | Imports Microsoft.VisualBasic.Terminal |
54 | |
55 | Namespace CommandLine.ManView |
56 | |
57 | ''' <summary> |
58 | ''' Defines the url or e-mail information for the exceptions. |
59 | ''' </summary> |
60 | <AttributeUsage(AttributeTargets.Class Or AttributeTargets.Method, AllowMultiple:=False, Inherited:=True)> |
61 | Public Class ExceptionHelp : Inherits Attribute |
62 | |
63 | ''' <summary> |
64 | ''' CLI tools' docs url |
65 | ''' </summary> |
66 | ''' <returns></returns> |
67 | Public Property Documentation As String |
68 | Public Property Debugging As String |
69 | ''' <summary> |
70 | ''' The author e-mail |
71 | ''' </summary> |
72 | ''' <returns></returns> |
73 | Public Property EMailLink As String |
74 | |
75 | Sub New() |
76 | End Sub |
77 | |
78 | Sub New(docs$, debug$, email$) |
79 | Documentation = docs |
80 | Debugging = debug |
81 | EMailLink = email |
82 | End Sub |
83 | |
84 | Public Overrides Function ToString() As String |
85 | Return Me.GetJson |
86 | End Function |
87 | End Class |
88 | |
89 | Public Module ExceptionHandler |
90 | |
91 | 'debuggroup summary 0.79s welcome To circos v0.69 6 Dec 2015 On Perl 5.018002 |
92 | 'debuggroup summary 0.80s current working directory /home/xieguigang/circos/bin |
93 | 'debuggroup summary 0.80s command ./circos [no flags] |
94 | 'debuggroup summary 0.80s guessing configuration file |
95 | 'Missing argument In sprintf at /home/xieguigang/circos/bin/../Lib/Circos/Error.pm line 356. |
96 | |
97 | ' *** CIRCOS ERROR *** |
98 | |
99 | ' cwd: /home/xieguigang/circos/bin |
100 | |
101 | ' command: ./circos |
102 | |
103 | ' CONFIGURATION FILE Error |
104 | |
105 | ' Circos could Not find the configuration file []. To run Circos, you need To |
106 | ' specify this file Using the -conf flag. The configuration file contains all |
107 | ' the parameters that define the image, including input files, image size, |
108 | ' formatting, etc. |
109 | |
110 | ' If you Do Not use the -conf flag, Circos will attempt To look For a file |
111 | ' circos.conf in several reasonable places such as . etc/ ../etc |
112 | |
113 | ' To see where Circos looks for the file, use |
114 | |
115 | ' circos -debug_flag io |
116 | |
117 | ' To see how configuration files work, create the example image, whose |
118 | ' configuration And data are found in example/. From the Circos distribution |
119 | ' directory, |
120 | |
121 | ' cd example |
122 | |
123 | ' ../bin/circos -conf ./circos.conf |
124 | |
125 | ' Or use the 'run' script (UNIX only). |
126 | |
127 | ' Configuration files are described here |
128 | |
129 | ' http://circos.ca/tutorials/lessons/configuration/configuration_files/ |
130 | |
131 | ' And the use of command-line flags, such as -conf, Is described here |
132 | |
133 | ' http://circos.ca/tutorials/lessons/configuration/runtime_parameters/ |
134 | |
135 | ' Windows users unfamiliar With Perl should read |
136 | |
137 | ' http://circos.ca/tutorials/lessons/configuration/unix_vs_windows/ |
138 | |
139 | ' This error can also be produced if supporting configuration files, such as |
140 | ' track defaults, cannot be read. |
141 | |
142 | ' If you are having trouble debugging this Error, first read the best practices |
143 | ' tutorial for helpful tips that address many common problems |
144 | |
145 | ' http://www.circos.ca/documentation/tutorials/reference/best_practices |
146 | |
147 | ' The debugging facility Is helpful To figure out what's happening under the |
148 | ' hood |
149 | |
150 | ' http://www.circos.ca/documentation/tutorials/configuration/debugging |
151 | |
152 | ' If you're still stumped, get support in the Circos Google Group. Please |
153 | ' include this Error And all your configuration And data files. |
154 | |
155 | ' http://groups.google.com/group/circos-data-visualization |
156 | |
157 | ' Stack trace : |
158 | ' at /home/xieguigang/circos/bin/../lib/Circos/Error.pm line 423. |
159 | ' Circos: Error: fatal_error('configuration', 'missing') called at /home/xieguigang/circos/bin/../lib/Circos.pm line 141 |
160 | ' Circos:run('Circos', '_argv', '', '_cwd', '/home/xieguigang/circos/bin') called at ./circos line 529 |
161 | |
162 | Public Sub Print(ex As Exception, method As MethodInfo) |
163 | Dim type As Type = method.DeclaringType |
164 | Dim helps As ExceptionHelp = type.GetAttribute(Of ExceptionHelp) |
165 | |
166 | If helps Is Nothing Then |
167 | helps = method.GetAttribute(Of ExceptionHelp) |
168 | End If |
169 | |
170 | If helps Is Nothing Then |
171 | Call ex.PrintException |
172 | Else |
173 | Call Console.WriteLine() |
174 | Call Console.WriteLine("Environment summary:") |
175 | Call Console.WriteLine(ConfigEngine.Prints(App.GetAppVariables)) |
176 | Call Console.WriteLine() |
177 | Call Console.WriteLine(App.CommandLine.Print(leftMargin:=2)) |
178 | Call Console.WriteLine() |
179 | Call Console.WriteLine() |
180 | Call Console.WriteLine("Exception: ") |
181 | Call STDIO.print(ex.Message, ConsoleColor.Red) |
182 | Call Console.WriteLine() |
183 | Call Console.WriteLine() |
184 | Call Console.WriteLine("If you are having trouble debugging this Error, first read the best practices") |
185 | Call Console.WriteLine("tutorial for helpful tips that address many common problems") |
186 | Call STDIO.print(helps.Documentation, ConsoleColor.Blue) |
187 | Call Console.WriteLine() |
188 | Call Console.WriteLine() |
189 | Call Console.WriteLine("The debugging facility Is helpful To figure out what's happening under the") |
190 | Call Console.WriteLine("hood") |
191 | Call STDIO.print(helps.Debugging, ConsoleColor.Blue) |
192 | Call Console.WriteLine() |
193 | Call Console.WriteLine() |
194 | Call Console.WriteLine("If you're still stumped, you can try get help from author directly from E-mail:") |
195 | Call STDIO.print(helps.EMailLink, ConsoleColor.Blue) |
196 | Call Console.WriteLine() |
197 | Call Console.WriteLine() |
198 | Call Console.WriteLine("Stack trace : ") |
199 | Call STDIO.print(ex.ToString, ConsoleColor.Red) |
200 | Call Console.WriteLine() |
201 | Call Console.WriteLine() |
202 | End If |
203 | End Sub |
204 | End Module |
205 | End Namespace |