View Javadoc

1   package cz.cuni.amis.pogamut.sposh.exceptions;
2   
3   import cz.cuni.amis.pogamut.sposh.elements.PoshElement;
4   import java.text.MessageFormat;
5   
6   /**
7    * The method was passed unexpected {@link PoshElement} as argument.
8    * @author HonzaH
9    */
10  public class UnexpectedElementException extends RuntimeException {
11  
12      /**
13       * Create new unexpected element exception, caller got unexpected {@link PoshElement}.
14       * @param element
15       * @return created exception
16       */
17      public static UnexpectedElementException create(PoshElement element) {
18          String elementName = element != null ? element.getClass().getCanonicalName() : "'null'";
19          String msg = MessageFormat.format("Unexpected lap element ({0}).", elementName);
20          return new UnexpectedElementException(msg);
21      }
22  
23      public UnexpectedElementException(String message) {
24          super(message);
25      }
26      
27  }