88
99namespace  Ibexa \AdminUi \Util ;
1010
11- use  RuntimeException ;
11+ use  Ibexa \ AdminUi \ Exception \ FieldTypeExpressionParserException ;
1212
1313final  class  ContentTypeFieldsExpressionParser implements  ContentTypeFieldsExpressionParserInterface
1414{
@@ -46,7 +46,7 @@ public function parseExpression(string $expression): array
4646                $ this  ->expectSlash ();
4747                $ fieldTokens  = $ this  ->parseSection ();
4848            } else  {
49-                 throw  new  RuntimeException ('Invalid expression, expected one or two T_SLASH delimiters. ' );
49+                 throw  new  FieldTypeExpressionParserException ('Invalid expression, expected one or two T_SLASH delimiters. ' );
5050            }
5151        }
5252
@@ -57,7 +57,7 @@ public function parseExpression(string $expression): array
5757        ];
5858
5959        if  (array_filter ($ parsedTokens ) === []) {
60-             throw  new  RuntimeException ('Choosing every possible content type field is not allowed. ' );
60+             throw  new  FieldTypeExpressionParserException ('Choosing every possible content type field is not allowed. ' );
6161        }
6262
6363        return  $ parsedTokens ;
@@ -71,7 +71,7 @@ private function parseSection(): ?array
7171        $ items  = [];
7272
7373        if  ($ this  ->lexer ->token  === null ) {
74-             throw  new  RuntimeException ('A token inside a section cannot be empty. ' );
74+             throw  new  FieldTypeExpressionParserException ('A token inside a section cannot be empty. ' );
7575        }
7676
7777        // Multiple elements between braces 
@@ -83,7 +83,7 @@ private function parseSection(): ?array
8383            }
8484
8585            if  (!$ this  ->lexer ->token ->isA (ContentTypeFieldsExpressionDoctrineLexer::T_RBRACE )) {
86-                 throw  new  RuntimeException ('Expected T_RBRACE to close the list. ' );
86+                 throw  new  FieldTypeExpressionParserException ('Expected T_RBRACE to close the list. ' );
8787            }
8888
8989            $ this  ->lexer ->moveNext ();
@@ -107,19 +107,19 @@ private function getTokenFromInsideBracket(): string
107107
108108        $ token  = $ this  ->expectIdentifierOrWildcard ();
109109        if  ($ token  === null ) {
110-             throw  new  RuntimeException ('Wildcards cannot be mixed with identifiers inside the expression. ' );
110+             throw  new  FieldTypeExpressionParserException ('Wildcards cannot be mixed with identifiers inside the expression. ' );
111111        }
112112
113113        return  $ token ;
114114    }
115115
116116    /** 
117-      * @throws \RuntimeException  
117+      * @throws \Ibexa\AdminUi\Exception\FieldTypeExpressionParserException  
118118     */ 
119119    private  function  expectSlash (): void 
120120    {
121121        if  ($ this  ->lexer ->token  === null ) {
122-             throw  new  RuntimeException (
122+             throw  new  FieldTypeExpressionParserException (
123123                sprintf (
124124                    'Expected token of type "%s" but got "null" ' ,
125125                    ContentTypeFieldsExpressionDoctrineLexer::T_SLASH ,
@@ -128,7 +128,7 @@ private function expectSlash(): void
128128        }
129129
130130        if  (!$ this  ->lexer ->token ->isA (ContentTypeFieldsExpressionDoctrineLexer::T_SLASH )) {
131-             throw  new  RuntimeException (
131+             throw  new  FieldTypeExpressionParserException (
132132                sprintf (
133133                    'Expected token of type "%s" but got "%s" ' ,
134134                    ContentTypeFieldsExpressionDoctrineLexer::T_SLASH ,
@@ -143,7 +143,7 @@ private function expectSlash(): void
143143    private  function  expectIdentifierOrWildcard (): ?string 
144144    {
145145        if  ($ this  ->lexer ->token  === null ) {
146-             throw  new  RuntimeException (
146+             throw  new  FieldTypeExpressionParserException (
147147                sprintf (
148148                    'Expected token of type "%s" but got "null" ' ,
149149                    ContentTypeFieldsExpressionDoctrineLexer::T_SLASH ,
@@ -159,7 +159,7 @@ private function expectIdentifierOrWildcard(): ?string
159159            ],
160160            true ,
161161        )) {
162-             throw  new  RuntimeException ('Expected an identifier or wildcard. ' );
162+             throw  new  FieldTypeExpressionParserException ('Expected an identifier or wildcard. ' );
163163        }
164164
165165        $ value  = $ this  ->lexer ->token ->isA (ContentTypeFieldsExpressionDoctrineLexer::T_WILDCARD )
0 commit comments