88use TypeLang \PHPDoc \Exception \ParsingException ;
99use TypeLang \PHPDoc \Exception \RuntimeExceptionInterface ;
1010use TypeLang \PHPDoc \Parser \Description \DescriptionParserInterface ;
11+ use TypeLang \PHPDoc \Tag \InvalidTag ;
1112use TypeLang \PHPDoc \Tag \Tag ;
1213use TypeLang \PHPDoc \Tag \Content ;
1314use TypeLang \PHPDoc \Tag \TagInterface ;
@@ -34,21 +35,22 @@ public function create(string $name, Content $content, DescriptionParserInterfac
3435
3536 if ($ delegate !== null ) {
3637 try {
37- return $ delegate ->create ($ name , $ content , $ descriptions );
38- } catch (ParsingException $ e ) {
39- throw $ e ;
38+ try {
39+ return $ delegate ->create ($ name , $ content , $ descriptions );
40+ } catch (RuntimeExceptionInterface $ e ) {
41+ throw $ e ;
42+ } catch (\Throwable $ e ) {
43+ throw InvalidTagException::fromCreatingTag (
44+ tag: $ name ,
45+ source: $ content ->value ,
46+ prev: $ e ,
47+ );
48+ }
4049 } catch (RuntimeExceptionInterface $ e ) {
41- throw InvalidTagException::fromCreatingTag (
42- tag: $ name ,
43- source: $ e ->getSource (),
44- offset: $ e ->getOffset (),
45- prev: $ e ,
46- );
47- } catch (\Throwable $ e ) {
48- throw InvalidTagException::fromCreatingTag (
49- tag: $ name ,
50- source: $ content ->value ,
51- prev: $ e ,
50+ return new InvalidTag (
51+ reason: $ e ,
52+ description: $ descriptions ->parse ($ content ->source ),
53+ name: $ name ,
5254 );
5355 }
5456 }
0 commit comments