Skip to content

Commit

Permalink
fix: improve error message for variant conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Sep 13, 2023
1 parent 729e277 commit f996001
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ export const variant = (index: number | number[] | string) => {
throw new BorshError(`Variant of ${ctor.name} have different type compared to its sibling: ${dependency.name}, expecting either number, number[] (with same sizes) or string, but not a combination of them`)
}
else if (index === otherVariant || (Array.isArray(index) && Array.isArray(otherVariant) && (index.length !== otherVariant.length || index.every((value, index) => value === (otherVariant as number[])[index])))) {
throw new BorshError(`Variant of ${ctor.name}: ${variant} is the same as for ${dependency.name} which is not allowed (non-determinism)`)
throw new BorshError(`Variant of ${ctor.name}: ${JSON.stringify(index)} is the same as for ${dependency.name} which is not allowed (non-determinism)`)

}
}
Expand Down

0 comments on commit f996001

Please sign in to comment.