Skip to content

Commit

Permalink
feat(operator): error handling for type dismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed May 19, 2019
1 parent 9b91ec9 commit 3354467
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export function operatorCalc(alg, result) {
return new inVector.constructor(x, y);
}
if (funRes) {
if (result.length === 3) {
return result(x, y, 0);
}
return result(x, y);
}

Expand All @@ -77,6 +80,9 @@ export function operatorCalc(alg, result) {
return new inVector.constructor(x, y, z);
}
if (funRes) {
if (result.length !== 3) {
throw new Error('You cant use 3D Operands for a 2D Result, better use xz, xy, yz getter');
}
return result(x, y, z);
}

Expand Down

0 comments on commit 3354467

Please sign in to comment.