Skip to content

Commit 541ebc4

Browse files
committed
fix: extend Exception for ResolutionError and provide non-overlapping methods
1 parent b1b6e25 commit 541ebc4

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

Diff for: features/bootstrap/FeatureContext.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public function theReasonShouldIndicateAnErrorAndTheErrorCodeShouldIndicateAMiss
359359
$error = $details->getError();
360360

361361
Assert::assertNotNull($error);
362-
Assert::assertEquals($errorCode, $error->getCode());
362+
Assert::assertEquals($errorCode, $error->getResolutionErrorCode());
363363
}
364364

365365
/**
@@ -392,7 +392,7 @@ public function theReasonShouldIndicateAnErrorAndTheErrorCodeShouldIndicateAType
392392

393393
Assert::assertNotNull($error);
394394
Assert::assertEquals(
395-
$error->getCode(),
395+
$error->getResolutionErrorCode(),
396396
ErrorCode::TYPE_MISMATCH(),
397397
);
398398
}

Diff for: src/implementation/provider/ResolutionError.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,29 @@
44

55
namespace OpenFeature\implementation\provider;
66

7+
use Exception;
78
use OpenFeature\interfaces\provider\ErrorCode;
89
use OpenFeature\interfaces\provider\ResolutionError as ResolutionErrorInterface;
910

10-
class ResolutionError implements ResolutionErrorInterface
11+
class ResolutionError extends Exception implements ResolutionErrorInterface
1112
{
12-
private ErrorCode $code;
13-
private ?string $message;
13+
private ErrorCode $resolutionErrorCode;
14+
private ?string $resolutionErrorMessage;
1415

1516
public function __construct(ErrorCode $code, ?string $message = null)
1617
{
17-
$this->code = $code;
18-
$this->message = $message;
18+
parent::__construct();
19+
$this->resolutionErrorCode = $code;
20+
$this->resolutionErrorMessage = $message;
1921
}
2022

21-
public function getCode(): ErrorCode
23+
public function getResolutionErrorCode(): ErrorCode
2224
{
23-
return $this->code;
25+
return $this->resolutionErrorCode;
2426
}
2527

26-
public function getMessage(): ?string
28+
public function getResolutionErrorMessage(): ?string
2729
{
28-
return $this->message;
30+
return $this->resolutionErrorMessage;
2931
}
3032
}

Diff for: src/interfaces/provider/ResolutionError.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface ResolutionError
2020
* In cases of abnormal execution, the provider MUST indicate an error using the idioms of the implementation
2121
* language, with an associated error code and optional associated error message.
2222
*/
23-
public function getCode(): ErrorCode;
23+
public function getResolutionErrorCode(): ErrorCode;
2424

2525
/**
2626
* ---------------
@@ -29,5 +29,5 @@ public function getCode(): ErrorCode;
2929
* In cases of abnormal execution, the provider MUST indicate an error using the idioms of the implementation
3030
* language, with an associated error code and optional associated error message.
3131
*/
32-
public function getMessage(): ?string;
32+
public function getResolutionErrorMessage(): ?string;
3333
}

Diff for: tests/unit/OpenFeatureClientTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function testClientEvaluationDetailsAbnormalExecutionHasErrorCodeField():
498498
/** @var ResolutionError $resolutionError */
499499
$resolutionError = $actualDetails->getError();
500500
$this->assertNotNull($resolutionError);
501-
$this->assertEquals($expectedErrorCode, $resolutionError->getCode());
501+
$this->assertEquals($expectedErrorCode, $resolutionError->getResolutionErrorCode());
502502
}
503503

504504
/**

Diff for: tests/unit/ProviderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function testMustPopulateErrorFieldInAbnormalExecution(): void
247247
/** @var ResolutionError $resolutionError */
248248
$resolutionError = $actualResolution->getError();
249249
$this->assertNotNull($resolutionError);
250-
$this->assertEquals($expectedErrorCode, $resolutionError->getCode());
250+
$this->assertEquals($expectedErrorCode, $resolutionError->getResolutionErrorCode());
251251
}
252252

253253
/**

0 commit comments

Comments
 (0)