Changeset 12350


Ignore:
Timestamp:
01/08/10 20:59:24 (11 years ago)
Author:
astalla
Message:

Added constructor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java

    r12298 r12350  
    3838public final class WrongNumberOfArgumentsException extends ProgramError
    3939{
    40     private final Operator operator;
     40    private Operator operator;
     41    private int expectedArgs;
     42    private String message;
    4143
    42     public WrongNumberOfArgumentsException(Operator operator)
     44    public WrongNumberOfArgumentsException(Operator operator) {
     45  this(operator, -1);
     46    }
    4347
    44     {
     48    public WrongNumberOfArgumentsException(Operator operator, int expectedArgs) {
    4549        // This is really just an ordinary PROGRAM-ERROR, broken out into its
    4650        // own Java class as a convenience for the implementation.
    4751        super(StandardClass.PROGRAM_ERROR);
    4852        this.operator = operator;
     53  this.expectedArgs = expectedArgs;
     54        setFormatControl(getMessage());
     55        setFormatArguments(NIL);
     56    }
     57
     58    public WrongNumberOfArgumentsException(String message) {
     59        super(StandardClass.PROGRAM_ERROR);
     60  if(message == null) {
     61      throw new NullPointerException("message can not be null");
     62  }
     63  this.message = message;
    4964        setFormatControl(getMessage());
    5065        setFormatArguments(NIL);
     
    5469    public String getMessage()
    5570    {
     71  if(message != null) {
     72      return message;
     73  }
    5674        FastStringBuffer sb =
    5775            new FastStringBuffer("Wrong number of arguments");
     
    6179            sb.append(operator.getLambdaName().writeToString());
    6280        }
     81  if(expectedArgs >= 0) {
     82      sb.append("; ");
     83      sb.append(expectedArgs);
     84      sb.append(" expected");
     85  }
    6386        sb.append('.');
    64         return sb.toString();
     87        return message = sb.toString();
    6588    }
    6689}
Note: See TracChangeset for help on using the changeset viewer.