Skip to content

Commit

Permalink
try implementing assert as if->throw
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanCrotaz committed Oct 18, 2024
1 parent 73653c3 commit 4cd3f0a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/mermaid/src/diagrams/packet/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ const getNextFittingBlock = (
row: number,
bitsPerRow: number
): [Required<PacketBlock>, PacketBlock | undefined] => {
assert(block.start !== undefined, 'start should have been set during first phase');
assert(block.end !== undefined, 'end should have been set during first phase');
if (block.start === undefined) {
throw new Error('start should have been set during first phase');
}
if (block.end === undefined) {
throw new Error('end should have been set during first phase');
}

if (block.start > block.end) {
throw new Error(`Block start ${block.start} is greater than block end ${block.end}.`);
Expand Down

0 comments on commit 4cd3f0a

Please sign in to comment.