fix(storage): add error handling for S3 connection error notifications
Wrap email notification logic in try-catch to prevent email sending failures from breaking the connection test. If notification fails, log a warning and continue instead of letting the exception propagate.
This commit is contained in:
parent
b878dc8102
commit
dbbc77830e
1 changed files with 16 additions and 12 deletions
|
|
@ -127,6 +127,7 @@ public function testConnection(bool $shouldSave = false)
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->is_usable = false;
|
$this->is_usable = false;
|
||||||
if ($this->unusable_email_sent === false && is_transactional_emails_enabled()) {
|
if ($this->unusable_email_sent === false && is_transactional_emails_enabled()) {
|
||||||
|
try {
|
||||||
$mail = new MailMessage;
|
$mail = new MailMessage;
|
||||||
$mail->subject('Coolify: S3 Storage Connection Error');
|
$mail->subject('Coolify: S3 Storage Connection Error');
|
||||||
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);
|
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);
|
||||||
|
|
@ -142,6 +143,9 @@ public function testConnection(bool $shouldSave = false)
|
||||||
send_user_an_email($mail, $user->email);
|
send_user_an_email($mail, $user->email);
|
||||||
}
|
}
|
||||||
$this->unusable_email_sent = true;
|
$this->unusable_email_sent = true;
|
||||||
|
} catch (\Throwable $emailException) {
|
||||||
|
\Log::warning('Failed to send S3 connection error notification: '.$emailException->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue