Skip to content

Commit 161e218

Browse files
committed
feat: Add TomlParserNotFound exception
1 parent c3098af commit 161e218

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Common/EnvConfig/Client/ConfigToml.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Temporal\Common\EnvConfig\Client;
66

77
use Internal\Toml\Toml;
8+
use Temporal\Common\EnvConfig\Exception\TomlParserNotFoundException;
89

910
/**
1011
* TOML configuration parser for Temporal client profiles.
@@ -57,6 +58,7 @@ public function __construct(
5758
string $toml,
5859
private readonly bool $strict = true,
5960
) {
61+
\class_exists(Toml::class) or throw new TomlParserNotFoundException();
6062
$data = Toml::parseToArray($toml);
6163
$this->profiles = $this->parseProfiles($data['profile'] ?? []);
6264
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Temporal\Common\EnvConfig\Exception;
6+
7+
/**
8+
* Thrown when the TOML parser package is not found.
9+
*/
10+
final class TomlParserNotFoundException extends ConfigException
11+
{
12+
public function __construct()
13+
{
14+
parent::__construct(
15+
'The package for parsing TOML files "internal/toml" is not found. ' .
16+
'Please install it via Composer: `composer require internal/toml`.',
17+
);
18+
}
19+
}

0 commit comments

Comments
 (0)