mamodom/node-parcheesi

Error management

Closed this issue · 1 comments

How can we emit errors? I'm trying to create a method that will move pawns around the board. Something like this:

//this would move pawn no. 0 or player mo. 0, 4 spaces
game.movePawn(0,0,4);

But this would be subject to many preconditions before executing: it's the user's turn, the pawn is not on the home area, the pawn has available spaces to move, an enemy barricade isn't blocking the way, etc.

What's the best way to emit the errors?

Found out how 😎