Skip to content

Commit 3647152

Browse files
committed
фAdded catch for failed launch logging (if the error message cannot be saved)
1 parent 16f73c8 commit 3647152

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Wrapper/TaskWrapper.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,18 @@ function ($code, $message, $file, $line) {
216216
$header,
217217
$e
218218
);
219-
$errors = $this->handler->completeLaunchUnsuccessfully($launchId, $message);
219+
try {
220+
$errors = $this->handler->completeLaunchUnsuccessfully($launchId, $message);
221+
} catch (Throwable $e) {
222+
$message = Formatter::exception(
223+
$this->config->getLogExceptionFormat(),
224+
$this->config->getMaxExceptionMsgLength(),
225+
$header,
226+
$e
227+
);
228+
$errors = $this->handler->completeLaunchUnsuccessfully($launchId, $message);
229+
}
230+
220231
if ($errors < $this->tries) {
221232
$this->logDebug($message);
222233
sleep($this->tryDelay);
@@ -551,7 +562,9 @@ private function phpErrorHandler($code, $message, $file, $line): void
551562
if (array_key_exists($code, PhpErrors::FATAL)) {
552563
$errName = PhpErrors::FATAL[$code];
553564
throw new Exception("(ATTENTION: PHP $errName) - $message", $code);
554-
} elseif ($this->config->getLogUncaughtErrors()) {
565+
}
566+
567+
if ($this->config->getLogUncaughtErrors()) {
555568
$message = (PhpErrors::SOFT[$code] ?? 0) . " - $message (code $code, file $file, line $line)";
556569
$this->config->getLogWarningsToError() ?
557570
$this->logError($message) :

0 commit comments

Comments
 (0)