44import static org .assertj .core .api .Assertions .assertThatCode ;
55import static org .assertj .core .api .Assertions .fail ;
66import static org .junit .jupiter .api .Assertions .assertEquals ;
7- import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
87import static org .junit .jupiter .api .Assertions .assertNotNull ;
98import static org .junit .jupiter .api .Assertions .assertTrue ;
109import static org .mockito .ArgumentMatchers .any ;
1615import static org .mockito .Mockito .verify ;
1716import static org .mockito .Mockito .when ;
1817
19- import dev .openfeature .sdk .exceptions .FlagNotFoundError ;
2018import dev .openfeature .sdk .fixtures .HookFixtures ;
2119import dev .openfeature .sdk .testutils .TestEventsProvider ;
2220import java .util .ArrayList ;
@@ -200,7 +198,7 @@ void error_hook_run_during_non_finally_stage() {
200198 Hook h = mockBooleanHook ();
201199 doThrow (RuntimeException .class ).when (h ).finallyAfter (any (), any (), any ());
202200
203- verify (h , times (0 )).error (any (), any (), any ());
201+ verify (h , times (0 )).error (any (), any (Exception . class ), any ());
204202 }
205203
206204 @ Test
@@ -225,16 +223,16 @@ void error_hook_must_run_if_resolution_details_returns_an_error_code() {
225223 invocationCtx ,
226224 FlagEvaluationOptions .builder ().hook (hook ).build ());
227225
228- ArgumentCaptor <Exception > captor = ArgumentCaptor .forClass (Exception .class );
226+ ArgumentCaptor <ErrorDetails > captor = ArgumentCaptor .forClass (ErrorDetails .class );
229227
230228 verify (hook , times (1 )).before (any (), any ());
231229 verify (hook , times (1 )).error (any (), captor .capture (), any ());
232230 verify (hook , times (1 )).finallyAfter (any (), any (), any ());
233231 verify (hook , never ()).after (any (), any (), any ());
234232
235- Exception exception = captor .getValue ();
236- assertEquals (errorMessage , exception . getMessage ());
237- assertInstanceOf ( FlagNotFoundError . class , exception );
233+ ErrorDetails errorDetails = captor .getValue ();
234+ assertEquals (errorMessage , errorDetails . getErrorMessage ());
235+ assertEquals ( ErrorCode . FLAG_NOT_FOUND , errorDetails . getErrorCode () );
238236 }
239237
240238 @ Specification (
@@ -279,7 +277,8 @@ public void after(
279277 }
280278
281279 @ Override
282- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
280+ public void error (
281+ HookContext <Boolean > ctx , ErrorDetails <Boolean > error , Map <String , Object > hints ) {
283282 evalOrder .add ("provider error" );
284283 }
285284
@@ -308,7 +307,7 @@ public void after(
308307 }
309308
310309 @ Override
311- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
310+ public void error (HookContext <Boolean > ctx , ErrorDetails < Boolean > error , Map <String , Object > hints ) {
312311 evalOrder .add ("api error" );
313312 }
314313
@@ -334,7 +333,7 @@ public void after(
334333 }
335334
336335 @ Override
337- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
336+ public void error (HookContext <Boolean > ctx , ErrorDetails < Boolean > error , Map <String , Object > hints ) {
338337 evalOrder .add ("client error" );
339338 }
340339
@@ -367,7 +366,8 @@ public void after(
367366 }
368367
369368 @ Override
370- public void error (HookContext <Boolean > ctx , Exception error , Map <String , Object > hints ) {
369+ public void error (
370+ 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