@@ -200,7 +200,7 @@ void error_hook_run_during_non_finally_stage() {
200
200
Hook h = mockBooleanHook ();
201
201
doThrow (RuntimeException .class ).when (h ).finallyAfter (any (), any (), any ());
202
202
203
- verify (h , times (0 )).error (any (), any (), any ());
203
+ verify (h , times (0 )).error (any (), any (Exception . class ), any ());
204
204
}
205
205
206
206
@ Test
@@ -225,16 +225,16 @@ void error_hook_must_run_if_resolution_details_returns_an_error_code() {
225
225
invocationCtx ,
226
226
FlagEvaluationOptions .builder ().hook (hook ).build ());
227
227
228
- ArgumentCaptor <Exception > captor = ArgumentCaptor .forClass (Exception .class );
228
+ ArgumentCaptor <ErrorDetails > captor = ArgumentCaptor .forClass (ErrorDetails .class );
229
229
230
230
verify (hook , times (1 )).before (any (), any ());
231
231
verify (hook , times (1 )).error (any (), captor .capture (), any ());
232
232
verify (hook , times (1 )).finallyAfter (any (), any (), any ());
233
233
verify (hook , never ()).after (any (), any (), any ());
234
234
235
- Exception exception = captor .getValue ();
236
- assertEquals (errorMessage , exception . getMessage ());
237
- assertInstanceOf ( FlagNotFoundError . class , exception );
235
+ ErrorDetails errorDetails = captor .getValue ();
236
+ assertEquals (errorMessage , errorDetails . getErrorMessage ());
237
+ assertEquals ( ErrorCode . FLAG_NOT_FOUND , errorDetails . getErrorCode () );
238
238
}
239
239
240
240
@ Specification (
@@ -279,7 +279,7 @@ public void after(
279
279
}
280
280
281
281
@ Override
282
- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
282
+ public void error (HookContext <Boolean > ctx , ErrorDetails < Boolean > error , Map <String , Object > hints ) {
283
283
evalOrder .add ("provider error" );
284
284
}
285
285
@@ -308,7 +308,7 @@ public void after(
308
308
}
309
309
310
310
@ Override
311
- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
311
+ public void error (HookContext <Boolean > ctx , ErrorDetails < Boolean > error , Map <String , Object > hints ) {
312
312
evalOrder .add ("api error" );
313
313
}
314
314
@@ -334,7 +334,7 @@ public void after(
334
334
}
335
335
336
336
@ Override
337
- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
337
+ public void error (HookContext <Boolean > ctx , ErrorDetails < Boolean > error , Map <String , Object > hints ) {
338
338
evalOrder .add ("client error" );
339
339
}
340
340
@@ -367,7 +367,7 @@ public void after(
367
367
}
368
368
369
369
@ Override
370
- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
370
+ public void error (HookContext <Boolean > ctx , ErrorDetails < Boolean > error , Map <String , Object > hints ) {
371
371
evalOrder .add ("invocation error" );
372
372
}
373
373
@@ -546,7 +546,7 @@ void error_hooks__before() {
546
546
new ImmutableContext (),
547
547
FlagEvaluationOptions .builder ().hook (hook ).build ());
548
548
verify (hook , times (1 )).before (any (), any ());
549
- verify (hook , times (1 )).error (any (), any (), any ());
549
+ verify (hook , times (1 )).error (any (), any (ErrorDetails . class ), any ());
550
550
assertEquals (false , value , "Falls through to the default." );
551
551
}
552
552
@@ -564,7 +564,7 @@ void error_hooks__after() {
564
564
new ImmutableContext (),
565
565
FlagEvaluationOptions .builder ().hook (hook ).build ());
566
566
verify (hook , times (1 )).after (any (), any (), any ());
567
- verify (hook , times (1 )).error (any (), any (), any ());
567
+ verify (hook , times (1 )).error (any (), any (ErrorDetails . class ), any ());
568
568
}
569
569
570
570
@ Test
@@ -609,7 +609,7 @@ void shortCircuit_flagResolution_runsHooksWithAllFields() {
609
609
FlagEvaluationOptions .builder ().hook (hook ).build ());
610
610
611
611
verify (hook ).before (any (), any ());
612
- verify (hook ).error (any (HookContext .class ), any (Exception .class ), any (Map .class ));
612
+ verify (hook ).error (any (HookContext .class ), any (ErrorDetails .class ), any (Map .class ));
613
613
verify (hook ).finallyAfter (any (HookContext .class ), any (FlagEvaluationDetails .class ), any (Map .class ));
614
614
}
615
615
@@ -655,8 +655,8 @@ void multi_hooks_early_out__before() {
655
655
verify (hook , times (1 )).before (any (), any ());
656
656
verify (hook2 , times (0 )).before (any (), any ());
657
657
658
- verify (hook , times (1 )).error (any (), any (), any ());
659
- verify (hook2 , times (1 )).error (any (), any (), any ());
658
+ verify (hook , times (1 )).error (any (), any (ErrorDetails . class ), any ());
659
+ verify (hook2 , times (1 )).error (any (), any (ErrorDetails . class ), any ());
660
660
}
661
661
662
662
@ Specification (number = "4.1.4" , text = "The evaluation context MUST be mutable only within the before hook." )
@@ -760,7 +760,7 @@ void first_finally_broken() {
760
760
void first_error_broken () {
761
761
Hook hook = mockBooleanHook ();
762
762
doThrow (RuntimeException .class ).when (hook ).before (any (), any ());
763
- doThrow (RuntimeException .class ).when (hook ).error (any (), any (), any ());
763
+ doThrow (RuntimeException .class ).when (hook ).error (any (), any (Exception . class ), any ());
764
764
Hook hook2 = mockBooleanHook ();
765
765
InOrder order = inOrder (hook , hook2 );
766
766
@@ -772,8 +772,8 @@ void first_error_broken() {
772
772
FlagEvaluationOptions .builder ().hook (hook2 ).hook (hook ).build ());
773
773
774
774
order .verify (hook ).before (any (), any ());
775
- order .verify (hook2 ).error (any (), any (), any ());
776
- order .verify (hook ).error (any (), any (), any ());
775
+ order .verify (hook2 ).error (any (), any (ErrorDetails . class ), any ());
776
+ order .verify (hook ).error (any (), any (ErrorDetails . class ), any ());
777
777
}
778
778
779
779
private Client getClient (FeatureProvider provider ) {
0 commit comments