8
8
use TypeLang \PHPDoc \Exception \ParsingException ;
9
9
use TypeLang \PHPDoc \Exception \RuntimeExceptionInterface ;
10
10
use TypeLang \PHPDoc \Parser \Description \DescriptionParserInterface ;
11
+ use TypeLang \PHPDoc \Tag \InvalidTag ;
11
12
use TypeLang \PHPDoc \Tag \Tag ;
12
13
use TypeLang \PHPDoc \Tag \Content ;
13
14
use TypeLang \PHPDoc \Tag \TagInterface ;
@@ -34,21 +35,22 @@ public function create(string $name, Content $content, DescriptionParserInterfac
34
35
35
36
if ($ delegate !== null ) {
36
37
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
+ }
40
49
} 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 ,
52
54
);
53
55
}
54
56
}
0 commit comments