File tree 2 files changed +20
-1
lines changed
validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ public ResponseHandler<TObject> withHandler(
78
78
return this ;
79
79
}
80
80
81
+ public ResponseHandler <TObject > withHandler (
82
+ final Handler <TObject > handler , final int ... responseCodes ) {
83
+ for (final int responseCode : responseCodes ) {
84
+ handlers .put (responseCode , handler );
85
+ }
86
+ return this ;
87
+ }
88
+
81
89
private Optional <TObject > defaultOkHandler (final Request request , final Response response )
82
90
throws IOException {
83
91
final ResponseBody responseBody = response .body ();
Original file line number Diff line number Diff line change 15
15
16
16
import static tech .pegasys .teku .ethereum .json .types .beacon .StateValidatorDataBuilder .STATE_VALIDATORS_RESPONSE_TYPE ;
17
17
import static tech .pegasys .teku .ethereum .json .types .beacon .StateValidatorRequestBodyType .STATE_VALIDATOR_REQUEST_TYPE ;
18
+ import static tech .pegasys .teku .infrastructure .http .HttpStatusCodes .SC_BAD_REQUEST ;
19
+ import static tech .pegasys .teku .infrastructure .http .HttpStatusCodes .SC_METHOD_NOT_ALLOWED ;
20
+ import static tech .pegasys .teku .infrastructure .http .HttpStatusCodes .SC_NOT_FOUND ;
18
21
import static tech .pegasys .teku .validator .remote .apiclient .ValidatorApiMethod .GET_VALIDATORS ;
19
22
20
23
import java .util .List ;
25
28
import tech .pegasys .teku .ethereum .json .types .beacon .StateValidatorData ;
26
29
import tech .pegasys .teku .ethereum .json .types .beacon .StateValidatorRequestBodyType ;
27
30
import tech .pegasys .teku .spec .datastructures .metadata .ObjectAndMetaData ;
31
+ import tech .pegasys .teku .validator .remote .apiclient .PostStateValidatorsNotExistingException ;
28
32
import tech .pegasys .teku .validator .remote .typedef .ResponseHandler ;
29
33
30
34
public class PostStateValidatorsRequest extends AbstractTypeDefRequest {
@@ -39,6 +43,13 @@ public Optional<ObjectAndMetaData<List<StateValidatorData>>> postStateValidators
39
43
Map .of (),
40
44
new StateValidatorRequestBodyType (validatorIds , List .of ()),
41
45
STATE_VALIDATOR_REQUEST_TYPE ,
42
- new ResponseHandler <>(STATE_VALIDATORS_RESPONSE_TYPE ));
46
+ new ResponseHandler <>(STATE_VALIDATORS_RESPONSE_TYPE )
47
+ .withHandler (
48
+ (request , response ) -> {
49
+ throw new PostStateValidatorsNotExistingException ();
50
+ },
51
+ SC_BAD_REQUEST ,
52
+ SC_NOT_FOUND ,
53
+ SC_METHOD_NOT_ALLOWED ));
43
54
}
44
55
}
You can’t perform that action at this time.
0 commit comments