Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Exception/IOException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Aternos\IO\Interfaces\IOElementInterface;
use Exception;
use Throwable;

/**
* Class IOException
Expand All @@ -17,10 +18,15 @@ class IOException extends Exception
/**
* @param string $message
* @param IOElementInterface|null $element
* @param Throwable|null $previous
*/
public function __construct(string $message = "", protected IOElementInterface|null $element = null)
public function __construct(
string $message = "",
protected IOElementInterface|null $element = null,
?Throwable $previous = null
)
{
parent::__construct($message);
parent::__construct($message, previous: $previous);
}

/**
Expand All @@ -30,4 +36,4 @@ public function getIOElement(): ?IOElementInterface
{
return $this->element;
}
}
}
9 changes: 8 additions & 1 deletion test/Unit/Exception/IOExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ public function testGetElement(): void
$exception = new IOException("test", $element);
$this->assertSame($element, $exception->getIOElement());
}
}

public function testGetPrevious(): void
{
$previous = new \Exception("previous");
$exception = new IOException("test", null, $previous);
$this->assertSame($previous, $exception->getPrevious());
}
}