Skip to content

Commit 4eaa76d

Browse files
authored
Merge pull request #8 from KurtThiemann/stdstreams-error-output
Use StdStreams instead of STDERR constant for error output
2 parents aaeb0fe + b237a0e commit 4eaa76d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/Proxy/ProxyRuntime.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Aternos\Taskmaster\Communication\Socket\Exception\SocketWriteException;
1313
use Aternos\Taskmaster\Communication\Socket\SelectableSocketInterface;
1414
use Aternos\Taskmaster\Communication\Socket\SocketCommunicatorTrait;
15+
use Aternos\Taskmaster\Communication\StdStreams;
1516
use Aternos\Taskmaster\Runtime\AsyncRuntimeInterface;
1617
use Aternos\Taskmaster\Taskmaster;
1718
use Aternos\Taskmaster\Worker\Instance\ProxyableWorkerInstanceInterface;
@@ -244,7 +245,7 @@ protected function handleFail(null|string|Exception $reason = null): static
244245
if ($reason instanceof Exception) {
245246
$reason = $reason->getMessage();
246247
}
247-
fwrite(STDERR, "Proxy runtime failed: " . $reason . PHP_EOL);
248+
fwrite(StdStreams::getInstance()->getStderr(), "Proxy runtime failed: " . $reason . PHP_EOL);
248249
exit(1);
249250
}
250-
}
251+
}

src/Runtime/SocketRuntime.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Aternos\Taskmaster\Communication\Socket\Socket;
99
use Aternos\Taskmaster\Communication\Socket\SocketCommunicatorTrait;
1010
use Aternos\Taskmaster\Communication\Socket\SocketInterface;
11+
use Aternos\Taskmaster\Communication\StdStreams;
1112
use Aternos\Taskmaster\Exception\PhpError;
1213
use Aternos\Taskmaster\Exception\PhpFatalErrorException;
1314
use Aternos\Taskmaster\Taskmaster;
@@ -102,7 +103,7 @@ protected function handleFail(null|string|Exception $reason = null): static
102103
if ($reason instanceof Exception) {
103104
$reason = $reason->getMessage();
104105
}
105-
fwrite(STDERR, "Runtime failed: " . $reason . PHP_EOL);
106+
fwrite(StdStreams::getInstance()->getStderr(), "Runtime failed: " . $reason . PHP_EOL);
106107
exit(1);
107108
}
108-
}
109+
}

src/Task/Task.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Aternos\Taskmaster\Communication\Promise\TaskPromise;
77
use Aternos\Taskmaster\Communication\Request\ExecuteFunctionRequest;
88
use Aternos\Taskmaster\Communication\ResponseInterface;
9+
use Aternos\Taskmaster\Communication\StdStreams;
910
use Aternos\Taskmaster\Exception\PhpError;
1011
use Aternos\Taskmaster\Runtime\RuntimeInterface;
1112
use Closure;
@@ -175,7 +176,7 @@ public function handleResult(mixed $result): void
175176
public function handleError(Exception $error): void
176177
{
177178
$this->error = $error;
178-
fwrite(STDERR, $error->getMessage() . PHP_EOL);
179+
fwrite(StdStreams::getInstance()->getStderr(), $error->getMessage() . PHP_EOL);
179180
}
180181

181182
/**
@@ -287,4 +288,4 @@ protected function isSync(): bool
287288
{
288289
return $this->sync;
289290
}
290-
}
291+
}

0 commit comments

Comments
 (0)