Skip to content

Commit b031f6d

Browse files
committed
feat: replace InvalidArgumentException with SysException for invalid status values in ArticleRecord
1 parent 55b20e1 commit b031f6d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

contexts/ArticlePublishing/Infrastructure/Records/ArticleRecord.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Contexts\ArticlePublishing\Infrastructure\Records;
66

7+
use App\Exceptions\SysException;
78
use App\Http\Models\BaseModel;
89
use Contexts\ArticlePublishing\Domain\Models\Article;
910
use Contexts\ArticlePublishing\Domain\Models\ArticleId;
@@ -35,7 +36,7 @@ class ArticleRecord extends BaseModel
3536
public static function mapStatusToDomain(int $status): ArticleStatus
3637
{
3738
if (! isset(self::STATUS_MAPPING[$status])) {
38-
throw new \InvalidArgumentException('Invalid status value');
39+
throw SysException::make('Invalid status value: '.$status);
3940
}
4041

4142
return new ArticleStatus(self::STATUS_MAPPING[$status]);
@@ -44,7 +45,7 @@ public static function mapStatusToDomain(int $status): ArticleStatus
4445
public static function mapStatusToRecord(ArticleStatus $status): int
4546
{
4647
if (! in_array($status->getValue(), self::STATUS_MAPPING)) {
47-
throw new \InvalidArgumentException('Invalid status value');
48+
throw SysException::make('Invalid status value: '.$status->getValue());
4849
}
4950

5051
return array_search($status->getValue(), self::STATUS_MAPPING);

0 commit comments

Comments
 (0)