Skip to content

Commit bc005a4

Browse files
committed
refactor: update exceptions to follow conventions
1 parent c9ea503 commit bc005a4

14 files changed

+46
-50
lines changed

packages/mailer/src/Attachments/FileAttachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Tempest\Mail\Attachments;
44

55
use Closure;
6-
use Tempest\Mail\Exceptions\CouldNotFindFileAttachmentException;
6+
use Tempest\Mail\Exceptions\FileAttachmentWasNotFound;
77
use Tempest\Support\Filesystem;
88
use Tempest\Support\Path;
99

@@ -30,7 +30,7 @@ public static function fromPath(string $path, ?string $name = null, ?string $con
3030
$path = Path\normalize($path);
3131

3232
if (! Filesystem\is_file($path)) {
33-
throw new CouldNotFindFileAttachmentException($path);
33+
throw new FileAttachmentWasNotFound($path);
3434
}
3535

3636
return new self(

packages/mailer/src/Content.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Tempest\Mail;
44

55
use Tempest\Mail\Attachments\Attachment;
6-
use Tempest\Mail\Exceptions\MissingContentException;
6+
use Tempest\Mail\Exceptions\MailContentWasMissing;
77
use Tempest\View\View;
88

99
/**
@@ -18,7 +18,7 @@ public function __construct(
1818
public array $attachments = [],
1919
) {
2020
if (! $text && ! $html) {
21-
throw new MissingContentException();
21+
throw new MailContentWasMissing();
2222
}
2323
}
2424
}

packages/mailer/src/EmailToSymfonyEmailMapper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Symfony\Component\Mime\Address as SymfonyAddress;
88
use Symfony\Component\Mime\Email as SymfonyEmail;
99
use Symfony\Component\Mime\Header\Headers;
10-
use Tempest\Mail\Exceptions\MissingExpeditorAddressException;
11-
use Tempest\Mail\Exceptions\MissingRecipientAddressException;
10+
use Tempest\Mail\Exceptions\ExpeditorWasMissing;
11+
use Tempest\Mail\Exceptions\RecipientWasMissing;
1212
use Tempest\Mapper\Mapper;
1313
use Tempest\Support\Arr;
1414
use Tempest\View\View;
@@ -47,13 +47,13 @@ public function map(mixed $from, mixed $to): SymfonyEmail
4747
} elseif ($this->mailerConfig->from) {
4848
$symfonyEmail->from($this->mailerConfig->from);
4949
} else {
50-
throw new MissingExpeditorAddressException();
50+
throw new ExpeditorWasMissing();
5151
}
5252

5353
if ($email->envelope->to) {
5454
$symfonyEmail->to(...$this->convertAddresses($email->envelope->to));
5555
} else {
56-
throw new MissingRecipientAddressException();
56+
throw new RecipientWasMissing();
5757
}
5858

5959
if ($email->envelope->cc) {

packages/mailer/src/Exceptions/CouldNotFindFileAttachmentException.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/mailer/src/Exceptions/MissingExpeditorAddressException.php renamed to packages/mailer/src/Exceptions/ExpeditorWasMissing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Exception;
66

7-
final class MissingExpeditorAddressException extends Exception implements MailerException
7+
final class ExpeditorWasMissing extends Exception implements MailerException
88
{
99
public function __construct()
1010
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Tempest\Mail\Exceptions;
4+
5+
use Exception;
6+
7+
final class FileAttachmentWasNotFound extends Exception implements MailerException
8+
{
9+
public function __construct(
10+
public readonly string $file,
11+
) {
12+
parent::__construct("File {$file} could not be found on the filesystem.");
13+
}
14+
}

packages/mailer/src/Exceptions/ForbiddenMailerUsageException.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/mailer/src/Exceptions/MissingContentException.php renamed to packages/mailer/src/Exceptions/MailContentWasMissing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Exception;
66

7-
final class MissingContentException extends Exception implements MailerException
7+
final class MailContentWasMissing extends Exception implements MailerException
88
{
99
public function __construct()
1010
{

packages/mailer/src/Exceptions/MissingTransportException.php renamed to packages/mailer/src/Exceptions/MailerTransportWasMissing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkApiTransport;
1010
use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkSmtpTransport;
1111

12-
final class MissingTransportException extends Exception implements MailerException
12+
final class MailerTransportWasMissing extends Exception implements MailerException
1313
{
1414
public function __construct(
1515
private readonly string $missing,

packages/mailer/src/Exceptions/MissingRecipientAddressException.php renamed to packages/mailer/src/Exceptions/RecipientWasMissing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Exception;
66

7-
final class MissingRecipientAddressException extends Exception implements MailerException
7+
final class RecipientWasMissing extends Exception implements MailerException
88
{
99
public function __construct()
1010
{

0 commit comments

Comments
 (0)