Error Message Changed

This commit is contained in:
RounakJoshi09
2023-10-11 20:40:14 +05:30
parent ce3d9fcdde
commit 995449cbf6
2 changed files with 15 additions and 14 deletions

View File

@@ -193,10 +193,11 @@ export const updateLinkInterpolate = function (positions, interp) {
export const updateLink = function (positions, style) { export const updateLink = function (positions, style) {
positions.forEach(function (pos) { positions.forEach(function (pos) {
if (pos >= edges.length) { if (pos >= edges.length) {
let error = new Error( throw new Error(
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)` `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') { if (pos === 'default') {
edges.defaultStyle = style; edges.defaultStyle = style;

View File

@@ -287,17 +287,17 @@ describe('[Style] when parsing', () => {
}); });
it('should handle style definitions within number of edges', function () { it('should handle style definitions within number of edges', function () {
try { expect(() =>
flow.parser.parse(`graph TD flow.parser
.parse(
`graph TD
A-->B A-->B
linkStyle 1 stroke-width:1px;`); linkStyle 1 stroke-width:1px;`
// Fail test if above expression doesn't throw anything. )
expect(true).toBe(false); .toThrow(
} catch (e) { '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.)'
expect(e.message).toBe( )
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
); );
}
}); });
it('should handle style definitions within number of edges', function () { it('should handle style definitions within number of edges', function () {