Add PSR-3 compliant exception context when logging exceptions (#300)
* Add PSR-3 exception context to caught error logs * Apply review feedback
This commit is contained in:
parent
bfc4728792
commit
73414d65f6
1 changed files with 88 additions and 27 deletions
|
|
@ -65,7 +65,7 @@ final class CallToolHandler implements RequestHandlerInterface
|
|||
try {
|
||||
$reference = $this->registry->getTool($toolName);
|
||||
} catch (ToolNotFoundException $e) {
|
||||
$this->logger->error('Tool not found', ['name' => $toolName]);
|
||||
$this->logger->error('Tool not found', ['name' => $toolName, 'exception' => $e]);
|
||||
|
||||
return new Error($request->getId(), Error::METHOD_NOT_FOUND, $e->getMessage());
|
||||
}
|
||||
|
|
@ -112,6 +112,7 @@ final class CallToolHandler implements RequestHandlerInterface
|
|||
$this->logger->error(\sprintf('Error while executing tool "%s": "%s".', $toolName, $e->getMessage()), [
|
||||
'tool' => $toolName,
|
||||
'arguments' => $arguments,
|
||||
'exception' => $e,
|
||||
]);
|
||||
|
||||
$errorContent = [new TextContent($e->getMessage())];
|
||||
|
|
|
|||
Loading…
Reference in a new issue