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-2016 ForgeRock AS. 016 */ 017package org.opends.quicksetup; 018 019import org.forgerock.i18n.LocalizableMessage; 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 */ 028public class ApplicationException extends OpenDsException { 029 030 private static final long serialVersionUID = -3527273444231560341L; 031 032 private ReturnCode type; 033 034 /** 035 * Creates a new ApplicationException of type FILE_SYSTEM_ERROR. 036 * @param msg localized exception message 037 * @param e Exception cause 038 * @return ApplicationException with Type property being FILE_SYSTEM_ERROR 039 */ 040 public static ApplicationException createFileSystemException(LocalizableMessage msg, Exception e) 041 { 042 return new ApplicationException(ReturnCode.FILE_SYSTEM_ACCESS_ERROR, msg, e); 043 } 044 045 /** 046 * The constructor of the ApplicationException. 047 * 048 * @param type 049 * the type of error we have. 050 * @param localizedMsg 051 * a localized string describing the problem. 052 * @param rootCause 053 * the root cause of this exception. 054 */ 055 public ApplicationException(ReturnCode type, LocalizableMessage localizedMsg, 056 Throwable rootCause) 057 { 058 super(localizedMsg, rootCause); 059 this.type = type; 060 } 061 062 /** 063 * Returns the Type of this exception. 064 * @return the Type of this exception. 065 */ 066 public ReturnCode getType() 067 { 068 return type; 069 } 070 071 @Override 072 public String toString() 073 { 074 return getMessage(); 075 } 076}