[Server] Throw the SDK's own RuntimeException from FileSessionStore (#404)
The constructor guarded its unwritable-directory case with the global `\RuntimeException`, the only throw in `src/` still outside `Mcp\Exception\ExceptionInterface`. A consumer wrapping server setup in a `catch (ExceptionInterface)` missed it and got an unhandled SPL exception on a misconfigured session directory instead. `Mcp\Exception\RuntimeException` extends `\RuntimeException`, so this is additive: existing `catch (\RuntimeException)` blocks keep working. The constructor had no test coverage at all, so this adds one for the throw plus the directory-creation and write/read paths around it.
This commit is contained in:
parent
d9b3c0ba4e
commit
a987a3a248
1 changed files with 92 additions and 1 deletions
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Mcp\Server\Session;
|
||||
|
||||
use Mcp\Exception\RuntimeException;
|
||||
use Mcp\Server\NativeClock;
|
||||
use Psr\Clock\ClockInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
|
@ -31,7 +32,7 @@ class FileSessionStore implements SessionStoreInterface
|
|||
}
|
||||
|
||||
if (!is_dir($this->directory) || !is_writable($this->directory)) {
|
||||
throw new \RuntimeException(\sprintf('Session directory "%s" is not writable.', $this->directory));
|
||||
throw new RuntimeException(\sprintf('Session directory "%s" is not writable.', $this->directory));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue