// Copyright (c) 1996-2002 Brian D. Carlstrom

package bdc.scheme.exception;

import bdc.scheme.SchemeException;
import bdc.scheme.Writer;
import bdc.util.Constants;
import bdc.util.Fmt;

public class BoundsException extends SchemeException
{
    Object object;
    int    size;
    int    argument;

    public BoundsException (Object object,
                            int size,
                            int argument)
    {
        this.object  = object;
        this.size    = size;
        this.argument= argument;
    }

    public String toString ()
    {
        return Fmt.S(
            "Attempt to access element %s" +
            " of %s" +
            " which is only %s long.",
            Constants.getInteger(argument), Writer.write(object),
            Constants.getInteger(size));
    }
}
