You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/EventStore.js
+11-17Lines changed: 11 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -397,11 +397,7 @@ class EventStore extends events.EventEmitter {
397
397
condition.raw
398
398
);
399
399
400
-
if(stream.next()!==false){
401
-
thrownewOptimisticConcurrencyError(
402
-
`Optimistic Concurrency error. A conflicting event was committed since the condition was obtained.`
403
-
);
404
-
}
400
+
assert(stream.next()===false,`Optimistic Concurrency error. A conflicting event was committed since the condition was obtained.`,OptimisticConcurrencyError);
405
401
}
406
402
407
403
/**
@@ -470,9 +466,10 @@ class EventStore extends events.EventEmitter {
470
466
}
471
467
assert(!this.streams[streamName].closed,`Stream "${streamName}" is closed and cannot be written to.`);
thrownewOptimisticConcurrencyError(`Optimistic Concurrency error. Expected stream "${streamName}" at version ${expectedVersion} but is at version ${streamVersion}.`);
`Optimistic Concurrency error. Expected stream "${streamName}" at version ${expectedVersion} but is at version ${streamVersion}.`,
471
+
OptimisticConcurrencyError
472
+
);
476
473
477
474
if(events.length>1){
478
475
deletemetadata.commitVersion;
@@ -550,14 +547,12 @@ class EventStore extends events.EventEmitter {
550
547
constqueryTypes=[];
551
548
for(consttypeoftypes){
552
549
if(!(typeinthis.streams)){
553
-
if(this.typeAccessor){
554
-
// typeAccessor is configured: type streams are created on commit, so a missing
555
-
// stream simply means no event of this type has been committed yet — treat as empty.
556
-
continue;
557
-
}
558
550
// No typeAccessor: the stream was never created; we cannot know whether events of
559
551
// this type exist in the store, so throw to avoid an unintentional full-store scan.
560
-
thrownewError(`Type stream "${type}" does not exist. Create it with createEventStream() first, or configure typeAccessor to have type streams created automatically on commit.`);
552
+
assert(!!this.typeAccessor,`Type stream "${type}" does not exist. Create it with createEventStream() first, or configure typeAccessor to have type streams created automatically on commit.`);
553
+
// typeAccessor is configured: type streams are created on commit, so a missing
554
+
// stream simply means no event of this type has been committed yet — treat as empty.
555
+
continue;
561
556
}
562
557
queryTypes.push(type);
563
558
}
@@ -675,9 +670,8 @@ class EventStore extends events.EventEmitter {
675
670
streamName.startsWith(categoryName+'/')
676
671
);
677
672
678
-
if(categoryStreams.length===0){
679
-
thrownewError(`No streams for category '${categoryName}' exist.`);
680
-
}
673
+
assert(categoryStreams.length>0,`No streams for category '${categoryName}' exist.`);
assert(headerMagic===HEADER_MAGIC,`Invalid file version. The index ${this.fileName} was created with a different library version (${headerMagic.substr(6)}).`);
assert(headerMagic===HEADER_MAGIC,`Invalid file version. The index ${this.fileName} was created with a different library version (${headerMagic.substring(6)}).`);
assert(headerMagic.substr(0,6)===HEADER_MAGIC.substr(0,6),`Invalid file header in partition ${this.name}.`);
119
+
assert(headerMagic.substring(0,6)===HEADER_MAGIC.substring(0,6),`Invalid file header in partition ${this.name}.`);
120
120
121
121
this.header=headerMagic;
122
-
assert(headerMagic===HEADER_MAGIC,`Invalid file version. The partition ${this.name} was created with a different library version (${headerMagic.substr(6)}).`);
122
+
assert(headerMagic===HEADER_MAGIC,`Invalid file version. The partition ${this.name} was created with a different library version (${headerMagic.substring(6)}).`);
0 commit comments