Skip to content

Commit e7a302f

Browse files
authored
fix: exceptions handling (#189)
* fix: exception handling * style: formatting * fix: return type
1 parent 9362bac commit e7a302f

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/Helpers/SitebossHelper.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function config(string $code, bool $failOnMissing = true): string|
4040
return self::$config[$code]['value'];
4141
}
4242

43-
public static function mail(string $to_name, string $to_email, string $subject, $html, $data = false)
43+
public static function mail(string $to_name, string $to_email, string $subject, $html, $data = false): ?int
4444
{
4545
$sendgrid_api_key = self::config('sendgrid_api_key', true);
4646
$sendgrid_sender_email = self::config('sendgrid_sender_email', true);
@@ -60,22 +60,16 @@ public static function mail(string $to_name, string $to_email, string $subject,
6060
}
6161
}
6262

63-
// if ($data != false) {
64-
// // HTML is a Twig template with data
65-
// if(!site::$page->twig)
66-
// {
67-
// site::$page->getTwig();
68-
// }
69-
// $html = site::$page->twig->render($html, $data);
70-
// }
7163
$email->addContent('text/html', $html);
7264
$sendgrid = new \SendGrid($sendgrid_api_key);
7365
try {
7466
$response = $sendgrid->send($email);
7567

7668
return $response->statusCode();
7769
} catch (\Exception $e) {
78-
echo 'Caught exception: '.$e->getMessage()."\n";
70+
Log::error('Caught exception: '.$e->getMessage());
71+
72+
return null;
7973
}
8074
}
8175

src/Services/ClamAV/ClamAV.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static function getClamAVSocket(): string
9494
$unixSocket = config('clamav.unix_socket');
9595

9696
return 'unix://'.$unixSocket;
97-
} else {
97+
} elseif ($preferredSocket === 'tcp') {
9898
$tcpSocket = config('clamav.tcp_socket');
9999

100100
return $tcpSocket;

0 commit comments

Comments
 (0)