1
1
package io .github .kloping .qqbot ;
2
2
3
- import io .github .kloping .MySpringTool .annotations .AutoStand ;
4
- import io .github .kloping .MySpringTool .annotations .AutoStandAfter ;
5
- import io .github .kloping .MySpringTool .annotations .Entity ;
6
- import io .github .kloping .MySpringTool .h1 .impl .LoggerImpl ;
7
- import io .github .kloping .MySpringTool .h1 .impl .component .HttpStatusReceiver ;
8
- import io .github .kloping .MySpringTool .interfaces .Logger ;
9
- import io .github .kloping .MySpringTool .interfaces .component .HttpClientManager ;
10
3
import io .github .kloping .common .Public ;
11
4
import io .github .kloping .qqbot .api .BotContent ;
12
5
import io .github .kloping .qqbot .entities .Bot ;
13
6
import io .github .kloping .qqbot .entities .qqpd .message .RawMessage ;
14
7
import io .github .kloping .qqbot .http .data .ActionResult ;
8
+ import io .github .kloping .qqbot .utils .RequestException ;
9
+ import io .github .kloping .spt .annotations .AutoStand ;
10
+ import io .github .kloping .spt .annotations .AutoStandAfter ;
11
+ import io .github .kloping .spt .annotations .Entity ;
12
+ import io .github .kloping .spt .impls .HttpStatusReceiver ;
13
+ import io .github .kloping .spt .impls .LoggerImpl ;
14
+ import io .github .kloping .spt .interfaces .Logger ;
15
+ import io .github .kloping .spt .interfaces .component .HttpClientManager ;
15
16
import org .fusesource .jansi .Ansi ;
16
17
import org .jsoup .Connection ;
17
18
import org .jsoup .nodes .Document ;
@@ -44,6 +45,7 @@ public void after(HttpClientManager manager) {
44
45
public void receive (HttpClientManager manager , String url , Integer code , Class <?> interface0 , Method method ,
45
46
Connection .Method reqMethod , Class <?> cla , Object o , Document metadata ) {
46
47
if (o == null || code == null || metadata == null ) return ;
48
+
47
49
logger .log (String .format ("Use the (%s) method through the (%s) interface to request " +
48
50
"the data obtained by the response code of the (%s) URL is (%s), " +
49
51
"and (%s) may be converted to (%s) type Will be processed and filtered" ,
@@ -57,7 +59,6 @@ public void receive(HttpClientManager manager, String url, Integer code, Class<?
57
59
Ansi .ansi ().fgRgb (LoggerImpl .NORMAL_LOW_COLOR .getRGB ()).a (o ).reset ().toString ()
58
60
));
59
61
fillAll (cla , o );
60
-
61
62
Public .EXECUTOR_SERVICE .submit (() -> {
62
63
if (o instanceof ActionResult ) {
63
64
ActionResult result = (ActionResult ) o ;
@@ -76,6 +77,9 @@ public void receive(HttpClientManager manager, String url, Integer code, Class<?
76
77
}
77
78
}
78
79
});
80
+ if (code >= 400 || code < 200 ) {
81
+ throw new RequestException (code , metadata .body ().wholeText (), url , method .getName ());
82
+ }
79
83
}
80
84
81
85
public void fillAll (Class <?> cla , Object o ) {
0 commit comments