Skip to content

API reference / @jsprismarine/predicates / DiagnosticCollector

Class: DiagnosticCollector ​

Defined in: diagnostics.ts:17

Gathers problems instead of throwing, so a malformed datapack reports every fault in one pass. Parse faults and evaluation faults share one collector, because a host usually wants both in the same report.

Constructors ​

Constructor ​

new DiagnosticCollector(): DiagnosticCollector

Returns ​

DiagnosticCollector

Properties ​

entries ​

readonly entries: Diagnostic[] = []

Defined in: diagnostics.ts:19

Every diagnostic reported so far, in the order it was reported.

Accessors ​

errors ​

Get Signature ​

get errors(): readonly Diagnostic[]

Defined in: diagnostics.ts:32

The subset of entries with error severity.

Returns ​

readonly Diagnostic[]

Methods ​

error() ​

error(path, message): void

Defined in: diagnostics.ts:22

Records a fault that makes the parsed value unusable or an evaluation give up.

Parameters ​

path ​

string

message ​

string

Returns ​

void


warn() ​

warn(path, message): void

Defined in: diagnostics.ts:27

Records a fault the evaluator recovered from, such as a grammar member it does not implement.

Parameters ​

path ​

string

message ​

string

Returns ​

void