package com.capgemini.reports.exceptions;

import com.capgemini.framework.teamcenter.exceptions.KurtException;

/** KURT functional input value errors ("not a number" etc). */
public class InvalidInputException extends KurtException {

    private static final long serialVersionUID = -8816332546502998913L;

    protected final UserInputErrorEnum userInputError;

    /**
     * Constructs an INTERNAL_ERROR, used when something went wrong while checking the user inputs.<br>
     * In this case, the user input could not be checked because an internal error occurred first.
     * 
     * @param aMessage a precise Error message for the developer
     */
    public InvalidInputException(final String aMessage) {
        super(aMessage);
        this.userInputError = UserInputErrorEnum.INTERNAL_ERROR;
    }

    /**
     * Constructs an Exception that may occur if the user provided some wrong inputs.<br>
     * A preset message will be sent to the user depending on the error.<br>
     * A preset message will be sent to the Exception log depending on the error.<br>
     * 
     * @param aUserInputError {@link UserInputErrorEnum} explaining what went wrong
     */
    public InvalidInputException(final UserInputErrorEnum aUserInputError) {
        super(aUserInputError.msgEn);
        this.userInputError = aUserInputError;
    }

    /**
     * Constructs an Exception that may occur if the user provided some wrong inputs.<br>
     * A preset message will be sent to the user depending on the error.<br>
     * A preset message will be sent to the Exception log depending on the error.<br>
     * 
     * @param aUserInputError {@link UserInputErrorEnum} explaining what went wrong
     * @param originalException the original exception
     */
    public InvalidInputException(final UserInputErrorEnum aUserInputError, final Throwable originalException) {
        super(aUserInputError.msgEn, originalException);
        this.userInputError = aUserInputError;
    }

    /**
     * Constructs an Exception that may occur if the user provided some wrong inputs.<br>
     * A preset message message will be sent to the user depending on the error.<br>
     * The specified message parameter will be sent to the Exception log and override the default one.<br>
     * 
     * @param aMessage a precise Error message for the programmer
     * @param aUserInputError {@link UserInputErrorEnum} explaining what went wrong
     */
    public InvalidInputException(final String aMessage, final UserInputErrorEnum aUserInputError) {
        super(aMessage);
        this.userInputError = aUserInputError;
    }

    /**
     * Constructs an INTERNAL_ERROR, used when something went wrong while checking the user inputs.<br>
     * In this case, the user input could not be checked because an internal error occurred first.<br>
     * The original exception is stored for reference.
     * 
     * @param aMessage a precise Error message for the developer
     * @param anException the original error
     */
    public InvalidInputException(final String aMessage, final Throwable anException) {
        super(aMessage, anException);
        this.userInputError = UserInputErrorEnum.INTERNAL_ERROR;
    }

    /**
     * Returns the message to be sent to the user.
     * 
     * @return the message
     */
    @Override
    public String getErrorMessageForUser() {
        return userInputError.msgFr;
    }

}
