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