|
4 | 4 |
|
5 | 5 | use Exception; |
6 | 6 | use Illuminate\Support\Facades\Log; |
| 7 | +use Throwable; |
7 | 8 | use OPGG\LaravelMcpServer\Data\ProcessMessageData; |
8 | 9 | use OPGG\LaravelMcpServer\Data\Requests\NotificationData; |
9 | 10 | use OPGG\LaravelMcpServer\Data\Requests\RequestData; |
@@ -127,13 +128,22 @@ public function handleMessage(string $clientId, array $message): ProcessMessageD |
127 | 128 |
|
128 | 129 | throw new JsonRpcErrorException(message: 'Invalid Request: Message format not recognized', code: JsonRpcErrorCode::INVALID_REQUEST); |
129 | 130 | } catch (JsonRpcErrorException $e) { |
| 131 | + report($e); |
130 | 132 | $jsonErrorResource = new JsonRpcErrorResource(exception: $e, id: $messageId); |
131 | 133 | $this->sendSSEMessage(clientId: $clientId, message: $jsonErrorResource); |
132 | 134 |
|
133 | 135 | return new ProcessMessageData(messageType: ProcessMessageType::HTTP, resource: $jsonErrorResource, isNotification: false); |
134 | | - } catch (Exception $e) { |
| 136 | + } catch (Throwable $e) { |
| 137 | + report($e); |
| 138 | + |
135 | 139 | $jsonErrorResource = new JsonRpcErrorResource( |
136 | | - exception: new JsonRpcErrorException(message: 'INTERNAL_ERROR', code: JsonRpcErrorCode::INTERNAL_ERROR), |
| 140 | + exception: new JsonRpcErrorException( |
| 141 | + message: $e->getMessage() ?: 'INTERNAL_ERROR', |
| 142 | + code: JsonRpcErrorCode::INTERNAL_ERROR, |
| 143 | + data: [ |
| 144 | + 'exception' => $e::class, |
| 145 | + ] |
| 146 | + ), |
137 | 147 | id: $messageId |
138 | 148 | ); |
139 | 149 | $this->sendSSEMessage(clientId: $clientId, message: $jsonErrorResource); |
|
0 commit comments