0

I have to implement my own exception (a GameException) which is thrown by the alpha beta algorithm in a nullsumm game. Is this correct?

import java.lang.Exception;

 public class GameException extends Exception { 

     public static final long serialVersionUID = 3654258946527845L;

     public static final String NoValidMoves = "There are noe valid moves!";


    GameException(String Message) {
        super(Message);
    }
    GameException() {

    }

}
Rui Vieira
  • 5,253
  • 5
  • 42
  • 55
  • I think your code is correct. In addtion to, you may add some custom methods for your exception class. For exaple; you throw an error code and your method matches the error code explanation and return it for exception message. Good luck ! – Tugrul Mar 08 '14 at 08:13

1 Answers1

3

It's correct.


FYI

  • You don't need to import java.lang.Exception. The java.lang part means that it is there by default.
  • By convention, variables in Java are lowerCamelCase.
  • You don't need to make serialVersionUID public. Any access modifier will work with Serializable, so usually private is chosen.
  • You misspelled "no".
Paul Draper
  • 78,542
  • 46
  • 206
  • 285
  • it **is** calling the no-arg constructor : http://stackoverflow.com/questions/2054022/unnecessary-to-put-super-in-constructor – Svetlin Zarev Mar 08 '14 at 17:27