1
1
2
2
package gudusoft .gsqlparser .sqlformatter .core ;
3
3
4
+ import gudusoft .gsqlparser .sqlformatter .SQLFormatPlugin ;
5
+
4
6
import java .io .BufferedReader ;
5
7
import java .io .IOException ;
6
8
import java .io .InputStreamReader ;
9
11
import java .net .URL ;
10
12
import java .net .URLEncoder ;
11
13
14
+ import org .eclipse .core .runtime .IStatus ;
15
+ import org .eclipse .core .runtime .Status ;
16
+ import org .eclipse .swt .widgets .Display ;
12
17
import org .json .JSONObject ;
13
18
14
19
public class SqlFormat
@@ -31,8 +36,20 @@ public String format( String sql, String formatOptions )
31
36
formatSql ) );
32
37
return jsonObject .getString ( "rspn_formatted_sql" );
33
38
}
34
- catch ( Exception e )
39
+ catch ( final Exception e )
35
40
{
41
+ Display .getDefault ( ).syncExec ( new Runnable ( ) {
42
+
43
+ public void run ( )
44
+ {
45
+ Status status = new Status ( IStatus .ERROR ,
46
+ SQLFormatPlugin .PLUGIN_ID ,
47
+ e .getMessage ( ),
48
+ e );
49
+ SQLFormatPlugin .getDefault ( ).getLog ( ).log ( status );
50
+ }
51
+ } );
52
+
36
53
}
37
54
return null ;
38
55
}
@@ -65,10 +82,19 @@ public String sendPost( String url, String param )
65
82
result += line ;
66
83
}
67
84
}
68
- catch ( Exception e )
85
+ catch ( final Exception e )
69
86
{
70
- System .out .println ( "Send post request failed!\n " + e );
71
- e .printStackTrace ( );
87
+ Display .getDefault ( ).syncExec ( new Runnable ( ) {
88
+
89
+ public void run ( )
90
+ {
91
+ Status status = new Status ( IStatus .ERROR ,
92
+ SQLFormatPlugin .PLUGIN_ID ,
93
+ "Send post request failed!" ,
94
+ e );
95
+ SQLFormatPlugin .getDefault ( ).getLog ( ).log ( status );
96
+ }
97
+ } );
72
98
}
73
99
finally
74
100
{
@@ -83,9 +109,19 @@ public String sendPost( String url, String param )
83
109
in .close ( );
84
110
}
85
111
}
86
- catch ( IOException ex )
112
+ catch ( final IOException ex )
87
113
{
88
- ex .printStackTrace ( );
114
+ Display .getDefault ( ).syncExec ( new Runnable ( ) {
115
+
116
+ public void run ( )
117
+ {
118
+ Status status = new Status ( IStatus .ERROR ,
119
+ SQLFormatPlugin .PLUGIN_ID ,
120
+ "Send post request failed!" ,
121
+ ex );
122
+ SQLFormatPlugin .getDefault ( ).getLog ( ).log ( status );
123
+ }
124
+ } );
89
125
}
90
126
}
91
127
return result ;
0 commit comments