Skip to content

Commit

Permalink
Error Message Changed
Browse files Browse the repository at this point in the history
  • Loading branch information
RounakJoshi09 committed Oct 11, 2023
1 parent ce3d9fc commit 995449c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions packages/mermaid/src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ export const updateLinkInterpolate = function (positions, interp) {
export const updateLink = function (positions, style) {
positions.forEach(function (pos) {
if (pos >= edges.length) {
let error = new Error(
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
throw new Error(

Check warning on line 196 in packages/mermaid/src/diagrams/flowchart/flowDb.js

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/diagrams/flowchart/flowDb.js#L196

Added line #L196 was not covered by tests
`The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${
edges.length - 1
}. (Help: Ensure that the index is within the range of existing edges.)`
);
throw error;
}
if (pos === 'default') {
edges.defaultStyle = style;
Expand Down
22 changes: 11 additions & 11 deletions packages/mermaid/src/diagrams/flowchart/parser/flow-style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,17 @@ describe('[Style] when parsing', () => {
});

it('should handle style definitions within number of edges', function () {
try {
flow.parser.parse(`graph TD
A-->B
linkStyle 1 stroke-width:1px;`);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe(
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
);
}
expect(() =>
flow.parser
.parse(
`graph TD
A-->B
linkStyle 1 stroke-width:1px;`
)
.toThrow(
'The index 1 for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and 0. (Help: Ensure that the index is within the range of existing edges.)'
)
);
});

it('should handle style definitions within number of edges', function () {
Expand Down

0 comments on commit 995449c

Please sign in to comment.