Slide 24
Slide 24 text
カスタム例外の定義例
final class CouldNotFindMeetup extends Exception
{
private function __construct(
string $message,
) {
parent::__construct($message);
}
public static function withId(
MeetupId $meetupId
): CouldNotFindMeetup {
return new self(
"Could not find a meetup with ID {$meeupId->value()}"
);
}
}
24