-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathRequestException.php
More file actions
40 lines (33 loc) · 929 Bytes
/
RequestException.php
File metadata and controls
40 lines (33 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Exception;
use Mcp\Schema\JsonRpc\Error;
/**
* Exception for MCP request failures.
*
* @author Kyrian Obikwelu <koshnawaza@gmail.com>
*/
class RequestException extends Exception
{
private ?Error $error;
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, ?Error $error = null)
{
parent::__construct($message, $code, $previous);
$this->error = $error;
}
public static function fromError(Error $error): self
{
return new self($error->message, $error->code, null, $error);
}
public function getError(): ?Error
{
return $this->error;
}
}