I am working on an othello game for class and am trying to raise an exception when the player makes a valid move but this exception is making my program crash and im not sure why. I get the error:
Traceback (most recent call last): File "C:\Users\chapp_000\Desktop\Othello\OthelloUI.py", line 46, in <module> s.makeMove(move[0],move[-1]) File "C:\Users\chapp_000\Desktop\Othello\OthelloGL.py", line 73, in makeMove raise InvalidMoveError() OthelloGL.InvalidMoveError Here is my exception class:
class InvalidMoveError(Exception): '''for handling bad moves''' pass And here is where the exception is being raised:
if self.checkCell(r,c) == 0: if self.turn ==1: self.board[r][c] = 2 self.turn =2 else: self.board[r][c] = 1 self.turn =1 elif self.checkCell(r,c) !=0: raise InvalidMoveError() EDIT: to answer some comments I am tying to us my exception to stop my program from crashing by saying pass and check cell looks on my board and returns 0 if no piece is their and 1 or 2 if that player has a piece their line 46 of the code is s.makeMove(move[0],move[-1]) where s is a game bored object and move is a list of 2 numbers from the player saying the x and y location they would like to move to