@@ -14,7 +14,7 @@ import { isAttributeNode, isClassNode } from "../BlockParser";
14
14
import { isRootNode , toAttrToken } from "../BlockParser" ;
15
15
import { BlockPath , CLASS_NAME_IDENT , DEFAULT_EXPORT , ROOT_CLASS } from "../BlockSyntax" ;
16
16
import { ResolvedConfiguration } from "../configuration" ;
17
- import { CssBlockError , InvalidBlockSyntax } from "../errors" ;
17
+ import { CssBlockError , InvalidBlockSyntax , MultipleCssBlockErrors } from "../errors" ;
18
18
import { FileIdentifier } from "../importing" ;
19
19
import { SourceFile , SourceRange } from "../SourceLocation" ;
20
20
@@ -51,6 +51,7 @@ export class Block
51
51
private _blockExportReverseLookup : Map < Block , string > = new Map ( ) ;
52
52
private _identifier : FileIdentifier ;
53
53
private _implements : Block [ ] = [ ] ;
54
+ private _blockErrors : CssBlockError [ ] = [ ] ;
54
55
private hasHadNameReset = false ;
55
56
56
57
public readonly guid : string ;
@@ -185,6 +186,25 @@ export class Block
185
186
return attr || klass || undefined ;
186
187
}
187
188
189
+ /**
190
+ * Stores a block error along with the block
191
+ * @param error CssBlockError that is added to the block
192
+ */
193
+ addError ( error : CssBlockError ) {
194
+ this . _blockErrors . push ( error ) ;
195
+ }
196
+
197
+ /**
198
+ * Checks for errors on the block
199
+ * @returns true if the block is valid else throws the errors on the block
200
+ */
201
+ assertValid ( ) : Boolean {
202
+ if ( this . _blockErrors . length ) {
203
+ throw new MultipleCssBlockErrors ( this . _blockErrors ) ;
204
+ }
205
+ return true ;
206
+ }
207
+
188
208
/**
189
209
* Add an absolute, normalized path as a compilation dependency. This is used
190
210
* to invalidate caches and trigger watchers when those files change.
0 commit comments