001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2015 ForgeRock AS.
016 */
017package org.opends.quicksetup;
018import org.forgerock.i18n.LocalizableMessage;
019
020import org.opends.server.types.OpenDsException;
021
022/**
023 * This exception is used to encapsulate all the error that we might have
024 * during the installation.
025 *
026 * @see org.opends.quicksetup.installer.Installer
027 * @see org.opends.quicksetup.installer.offline.OfflineInstaller
028 */
029public class ApplicationException extends OpenDsException {
030
031  private static final long serialVersionUID = -3527273444231560341L;
032
033  private ReturnCode type;
034
035  /**
036   * Creates a new ApplicationException of type FILE_SYSTEM_ERROR.
037   * @param msg localized exception message
038   * @param e Exception cause
039   * @return ApplicationException with Type property being FILE_SYSTEM_ERROR
040   */
041  public static ApplicationException createFileSystemException(LocalizableMessage msg,
042      Exception e)
043  {
044    return new ApplicationException(ReturnCode.FILE_SYSTEM_ACCESS_ERROR,
045        msg, e);
046  }
047
048  /**
049   * The constructor of the ApplicationException.
050   *
051   * @param type
052   *          the type of error we have.
053   * @param localizedMsg
054   *          a localized string describing the problem.
055   * @param rootCause
056   *          the root cause of this exception.
057   */
058  public ApplicationException(ReturnCode type, LocalizableMessage localizedMsg,
059                              Throwable rootCause)
060  {
061    super(localizedMsg, rootCause);
062    this.type = type;
063  }
064
065  /**
066   * Returns the Type of this exception.
067   * @return the Type of this exception.
068   */
069  public ReturnCode getType()
070  {
071    return type;
072  }
073
074  /** {@inheritDoc} */
075  public String toString()
076  {
077    return getMessage();
078  }
079}