Skip to content

Commit c291f33

Browse files
committed
fix(ProcessTimedOutException): Include timeout type and value in message
1 parent 873483a commit c291f33

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
<?php
22

3-
43
namespace Verseles\Flyclone\Exception;
54

5+
use Symfony\Component\Process\Exception\ProcessTimedOutException as SymfonyProcessTimedOutException;
66

77
class ProcessTimedOutException extends RcloneException
88
{
9-
public function __construct(\Exception $exception, string $message = 'The process took more than defined.', int $code = 22)
10-
{
11-
parent::__construct($message, $code, $exception);
12-
}
13-
}
9+
/**
10+
* @param SymfonyProcessTimedOutException $exception The original exception from Symfony Process.
11+
* @param int $code The exception code.
12+
*/
13+
public function __construct(SymfonyProcessTimedOutException $exception, int $code = 22)
14+
{
15+
$message = 'The process timed out.'; // Default message
16+
17+
// Determine which timeout was exceeded by inspecting the Symfony exception object.
18+
if ($exception->isIdleTimeout()) {
19+
$message = sprintf('The process exceeded the idle timeout of %s seconds.', $exception->getIdleTimeout());
20+
} elseif ($exception->isGeneralTimeout()) {
21+
$message = sprintf('The process exceeded the total timeout of %s seconds.', $exception->getTimeout());
22+
}
23+
24+
parent::__construct($message, $code, $exception);
25+
}
26+
}

0 commit comments

Comments
 (0)