Skip to content

Commit

Permalink
fix: exceptions handling (#189)
Browse files Browse the repository at this point in the history
* fix: exception handling

* style: formatting

* fix: return type
  • Loading branch information
64knl authored Jan 31, 2024
1 parent 9362bac commit e7a302f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/Helpers/SitebossHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function config(string $code, bool $failOnMissing = true): string|
return self::$config[$code]['value'];
}

public static function mail(string $to_name, string $to_email, string $subject, $html, $data = false)
public static function mail(string $to_name, string $to_email, string $subject, $html, $data = false): ?int
{
$sendgrid_api_key = self::config('sendgrid_api_key', true);
$sendgrid_sender_email = self::config('sendgrid_sender_email', true);
Expand All @@ -60,22 +60,16 @@ public static function mail(string $to_name, string $to_email, string $subject,
}
}

// if ($data != false) {
// // HTML is a Twig template with data
// if(!site::$page->twig)
// {
// site::$page->getTwig();
// }
// $html = site::$page->twig->render($html, $data);
// }
$email->addContent('text/html', $html);
$sendgrid = new \SendGrid($sendgrid_api_key);
try {
$response = $sendgrid->send($email);

return $response->statusCode();
} catch (\Exception $e) {
echo 'Caught exception: '.$e->getMessage()."\n";
Log::error('Caught exception: '.$e->getMessage());

return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Services/ClamAV/ClamAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static function getClamAVSocket(): string
$unixSocket = config('clamav.unix_socket');

return 'unix://'.$unixSocket;
} else {
} elseif ($preferredSocket === 'tcp') {
$tcpSocket = config('clamav.tcp_socket');

return $tcpSocket;
Expand Down

0 comments on commit e7a302f

Please sign in to comment.