@@ -200,7 +200,7 @@ void error_hook_run_during_non_finally_stage() {
200200 Hook h = mockBooleanHook ();
201201 doThrow (RuntimeException .class ).when (h ).finallyAfter (any (), any (), any ());
202202
203- verify (h , times (0 )).error (any (), any (), any ());
203+ verify (h , times (0 )).error (any (), any (Exception . class ), any ());
204204 }
205205
206206 @ Test
@@ -225,16 +225,16 @@ void error_hook_must_run_if_resolution_details_returns_an_error_code() {
225225 invocationCtx ,
226226 FlagEvaluationOptions .builder ().hook (hook ).build ());
227227
228- ArgumentCaptor <Exception > captor = ArgumentCaptor .forClass (Exception .class );
228+ ArgumentCaptor <ErrorDetails > captor = ArgumentCaptor .forClass (ErrorDetails .class );
229229
230230 verify (hook , times (1 )).before (any (), any ());
231231 verify (hook , times (1 )).error (any (), captor .capture (), any ());
232232 verify (hook , times (1 )).finallyAfter (any (), any (), any ());
233233 verify (hook , never ()).after (any (), any (), any ());
234234
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 () );
238238 }
239239
240240 @ Specification (
@@ -279,7 +279,7 @@ public void after(
279279 }
280280
281281 @ 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 ) {
283283 evalOrder .add ("provider error" );
284284 }
285285
@@ -308,7 +308,7 @@ public void after(
308308 }
309309
310310 @ 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 ) {
312312 evalOrder .add ("api error" );
313313 }
314314
@@ -334,7 +334,7 @@ public void after(
334334 }
335335
336336 @ 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 ) {
338338 evalOrder .add ("client error" );
339339 }
340340
@@ -367,7 +367,7 @@ public void after(
367367 }
368368
369369 @ 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 ) {
371371 evalOrder .add ("invocation error" );
372372 }
373373
@@ -546,7 +546,7 @@ void error_hooks__before() {
546546 new ImmutableContext (),
547547 FlagEvaluationOptions .builder ().hook (hook ).build ());
548548 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 ());
550550 assertEquals (false , value , "Falls through to the default." );
551551 }
552552
@@ -564,7 +564,7 @@ void error_hooks__after() {
564564 new ImmutableContext (),
565565 FlagEvaluationOptions .builder ().hook (hook ).build ());
566566 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 ());
568568 }
569569
570570 @ Test
@@ -609,7 +609,7 @@ void shortCircuit_flagResolution_runsHooksWithAllFields() {
609609 FlagEvaluationOptions .builder ().hook (hook ).build ());
610610
611611 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 ));
613613 verify (hook ).finallyAfter (any (HookContext .class ), any (FlagEvaluationDetails .class ), any (Map .class ));
614614 }
615615
@@ -655,8 +655,8 @@ void multi_hooks_early_out__before() {
655655 verify (hook , times (1 )).before (any (), any ());
656656 verify (hook2 , times (0 )).before (any (), any ());
657657
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 ());
660660 }
661661
662662 @ 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() {
760760 void first_error_broken () {
761761 Hook hook = mockBooleanHook ();
762762 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 ());
764764 Hook hook2 = mockBooleanHook ();
765765 InOrder order = inOrder (hook , hook2 );
766766
@@ -772,8 +772,8 @@ void first_error_broken() {
772772 FlagEvaluationOptions .builder ().hook (hook2 ).hook (hook ).build ());
773773
774774 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 ());
777777 }
778778
779779 private Client getClient (FeatureProvider provider ) {
0 commit comments