001package Torello.Browser;
002
003/**
004 * This exception throws if, when building a CDP instance with the 'advanced' {@link TypeBuilder}
005 * class, but a unknown field name has been passed by the user.  The class {@link TypeBuilder} may 
006 * be used in lieu of a class' constructor for a CDP data class in situation where the constructor 
007 * would be completely unwieldy and inconvenient given the number of fields in the class.
008 * 
009 * <BR /><BR /><DIV CLASS=JDHint>
010 * 👉 This class offers a number of "convenience fields" to provide more comprehensive error 
011 * reporting when something has failed.
012 * </DIV>
013 * 
014 * @see TypeBuilder
015 */
016public class AssignmentNameException extends IllegalArgumentException
017{
018    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUIDEX>  */
019    public static final long serialVersionUID = 1;
020
021    /**
022     * The unknown assignment name that was passed to one of the builder's
023     * {@code accept(...)} methods.
024     * 
025     * <BR /><BR /><DIV CLASS=JDHint>
026     * 👉 For a {@link TypeBuilder}, this name usually identifies a field in the CDP type being
027     * built.  For a {@link CommandBuilder}, it usually identifies one of the command's input
028     * parameters.
029     * </DIV>
030     */
031    public final String name;
032
033    /**
034     * The descriptor used by the builder when this exception was thrown.
035     * 
036     * <BR /><BR /><DIV CLASS=JDHint>
037     * 👉 This field is provided as a programmer convenience, to make debugging and error
038     * investigation easier.
039     * </DIV>
040     */
041    public final AbstractDescriptor descriptor;
042
043    /**
044     * Constructs a {@code AssignmentNameException} with the default error message.
045     * 
046     * @param name the unknown assignment name passed to the builder.
047     * @param descriptor the descriptor used by the builder.
048     */
049    public AssignmentNameException(final String name, final AbstractDescriptor descriptor)
050    {
051        super("The assignment name \"" + name + "\" is not listed by this builder's descriptor.");
052        this.name       = name;
053        this.descriptor = descriptor;
054    }
055
056    /**
057     * Constructs a {@code AssignmentNameException} with the specified detail message.
058     * 
059     * @param message the detail message.
060     * @param name the unknown assignment name passed to the builder.
061     * @param descriptor the descriptor used by the builder.
062    */
063    public AssignmentNameException(
064            final String                message,
065            final String                name,
066            final AbstractDescriptor    descriptor
067        )
068    {
069        super(message);
070        this.name       = name;
071        this.descriptor = descriptor;
072    }
073}
074