1616use Mcp \Capability \Registry \PromptReference ;
1717use Mcp \Capability \Registry \ReferenceHandlerInterface ;
1818use Mcp \Capability \Registry \ReferenceProviderInterface ;
19+ use Mcp \Exception \PromptGetException ;
20+ use Mcp \Exception \PromptNotFoundException ;
1921use Mcp \Exception \RegistryException ;
2022use Mcp \Exception \RuntimeException ;
2123use Mcp \Schema \Content \PromptMessage ;
@@ -151,8 +153,8 @@ public function testGetThrowsInvalidArgumentExceptionWhenPromptNotFound(): void
151153 ->expects ($ this ->never ())
152154 ->method ('handle ' );
153155
154- $ this ->expectException (\InvalidArgumentException ::class);
155- $ this ->expectExceptionMessage ('Prompt "nonexistent_prompt" is not registered . ' );
156+ $ this ->expectException (PromptNotFoundException ::class);
157+ $ this ->expectExceptionMessage ('Prompt not found for name: "nonexistent_prompt" . ' );
156158
157159 $ this ->promptGetter ->get ($ request );
158160 }
@@ -176,7 +178,7 @@ public function testGetThrowsRegistryExceptionWhenHandlerFails(): void
176178 ->with ($ promptReference , ['param ' => 'value ' ])
177179 ->willThrowException ($ handlerException );
178180
179- $ this ->expectException (RegistryException ::class);
181+ $ this ->expectException (PromptGetException ::class);
180182
181183 $ this ->promptGetter ->get ($ request );
182184 }
@@ -204,7 +206,7 @@ public function testGetHandlesJsonExceptionDuringFormatting(): void
204206 ->with ($ promptReference , [])
205207 ->willReturn ('some result ' );
206208
207- $ this ->expectException (\JsonException ::class);
209+ $ this ->expectException (PromptGetException ::class);
208210 $ this ->expectExceptionMessage ('JSON encoding failed ' );
209211
210212 $ this ->promptGetter ->get ($ request );
@@ -333,31 +335,6 @@ public function testGetHandlesEmptyArrayResult(): void
333335 $ this ->assertCount (0 , $ result ->messages );
334336 }
335337
336- public function testGetHandlesDifferentExceptionTypes (): void
337- {
338- $ request = new GetPromptRequest ('error_prompt ' , []);
339- $ prompt = $ this ->createValidPrompt ('error_prompt ' );
340- $ promptReference = new PromptReference ($ prompt , fn () => throw new \InvalidArgumentException ('Invalid input ' ));
341- $ handlerException = new \InvalidArgumentException ('Invalid input ' );
342-
343- $ this ->referenceProvider
344- ->expects ($ this ->once ())
345- ->method ('getPrompt ' )
346- ->with ('error_prompt ' )
347- ->willReturn ($ promptReference );
348-
349- $ this ->referenceHandler
350- ->expects ($ this ->once ())
351- ->method ('handle ' )
352- ->with ($ promptReference , [])
353- ->willThrowException ($ handlerException );
354-
355- $ this ->expectException (\InvalidArgumentException::class);
356- $ this ->expectExceptionMessage ('Invalid input ' );
357-
358- $ this ->promptGetter ->get ($ request );
359- }
360-
361338 public function testGetWithTypedContentStructure (): void
362339 {
363340 $ request = new GetPromptRequest ('typed_content_prompt ' , []);
@@ -512,7 +489,7 @@ public function testGetThrowsRuntimeExceptionForInvalidHandlerResult(): void
512489 ->with ($ promptReference , [])
513490 ->willReturn ('This is not a valid prompt format ' );
514491
515- $ this ->expectException (RuntimeException ::class);
492+ $ this ->expectException (PromptGetException ::class);
516493 $ this ->expectExceptionMessage ('Prompt generator method must return an array of messages. ' );
517494
518495 $ this ->promptGetter ->get ($ request );
@@ -539,7 +516,7 @@ public function testGetThrowsRuntimeExceptionForNullHandlerResult(): void
539516 ->with ($ promptReference , [])
540517 ->willReturn (null );
541518
542- $ this ->expectException (RuntimeException ::class);
519+ $ this ->expectException (PromptGetException ::class);
543520 $ this ->expectExceptionMessage ('Prompt generator method must return an array of messages. ' );
544521
545522 $ this ->promptGetter ->get ($ request );
@@ -566,7 +543,7 @@ public function testGetThrowsRuntimeExceptionForScalarHandlerResult(): void
566543 ->with ($ promptReference , [])
567544 ->willReturn (42 );
568545
569- $ this ->expectException (RuntimeException ::class);
546+ $ this ->expectException (PromptGetException ::class);
570547 $ this ->expectExceptionMessage ('Prompt generator method must return an array of messages. ' );
571548
572549 $ this ->promptGetter ->get ($ request );
@@ -593,7 +570,7 @@ public function testGetThrowsRuntimeExceptionForBooleanHandlerResult(): void
593570 ->with ($ promptReference , [])
594571 ->willReturn (true );
595572
596- $ this ->expectException (RuntimeException ::class);
573+ $ this ->expectException (PromptGetException ::class);
597574 $ this ->expectExceptionMessage ('Prompt generator method must return an array of messages. ' );
598575
599576 $ this ->promptGetter ->get ($ request );
@@ -622,7 +599,7 @@ public function testGetThrowsRuntimeExceptionForObjectHandlerResult(): void
622599 ->with ($ promptReference , [])
623600 ->willReturn ($ objectResult );
624601
625- $ this ->expectException (RuntimeException ::class);
602+ $ this ->expectException (PromptGetException ::class);
626603 $ this ->expectExceptionMessage ('Prompt generator method must return an array of messages. ' );
627604
628605 $ this ->promptGetter ->get ($ request );
0 commit comments