Skip to content

Commit

Permalink
wrap with mns result
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhineng committed Dec 24, 2024
1 parent e6b3ec0 commit bf2b792
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/AcsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public function setResult(Result $result): static
}

/**
* Get the underlying result.
*
* @return \Dew\Acs\Result<array<mixed>>|null
*/
public function getResult(): ?Result
public function getResult()
{
return $this->result;
}
Expand Down
12 changes: 12 additions & 0 deletions src/MnsOpen/QueueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Dew\Acs\MnsOpen;

use Dew\Acs\AcsException;
use Dew\Acs\MnsOpen\Results\MnsResult;
use Dew\Acs\Result;
use Override;

Expand Down Expand Up @@ -66,4 +67,15 @@ private static function makeFromMultipleErrors(Result $result): static

return (new static($message, $code))->setResult($result);
}

/**
* Get the underlying result.
*
* @return \Dew\Acs\MnsOpen\Results\MnsResult|null
*/
#[Override]
public function getResult()
{
return $this->result ? new MnsResult($this->result) : null;
}
}
2 changes: 2 additions & 0 deletions tests/MnsOpen/QueueExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Dew\Acs\Tests\MnsOpen;

use Dew\Acs\MnsOpen\QueueException;
use Dew\Acs\MnsOpen\Results\MnsResult;
use Dew\Acs\Result;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
Expand All @@ -17,6 +18,7 @@ public function test_query_exception_should_be_thrown(): void
$e = QueueException::makeFromResult(new Result(['Error' => ['Code' => 'Unknown', 'Message' => 'Something went wrong!']]));
$this->assertSame('Something went wrong!', $e->getMessage());
$this->assertSame('Unknown', $e->getCode());
$this->assertInstanceOf(MnsResult::class, $e->getResult());
}

public function test_result_contains_multiple_error_messages_1_other(): void
Expand Down

0 comments on commit bf2b792

Please sign in to comment.