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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Hyde\Framework\Exceptions;

use Throwable;
use Hyde\Facades\Filesystem;
use InvalidArgumentException;

Expand All @@ -13,13 +14,13 @@

class InvalidConfigurationException extends InvalidArgumentException
{
public function __construct(string $message = 'Invalid configuration detected.', ?string $namespace = null, ?string $key = null)
public function __construct(string $message = 'Invalid configuration detected.', ?string $namespace = null, ?string $key = null, ?Throwable $previous = null)
{
if ($namespace && $key) {
[$this->file, $this->line] = $this->findConfigLine($namespace, $key);
}

parent::__construct($message);
parent::__construct($message, previous: $previous);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions packages/framework/tests/Unit/CustomExceptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,13 @@ public function testInvalidConfigurationExceptionWithNamespaceAndKey()
$this->assertStringContainsString('config'.DIRECTORY_SEPARATOR.'hyde.php', $exception->getFile());
$this->assertGreaterThan(0, $exception->getLine());
}

public function testInvalidConfigurationExceptionWithPreviousThrowable()
{
$previous = new Exception('Previous exception.');
$exception = new InvalidConfigurationException('Invalid configuration.', 'hyde', 'name', $previous);

$this->assertSame('Invalid configuration.', $exception->getMessage());
$this->assertSame($previous, $exception->getPrevious());
}
}